@@ -139,22 +139,33 @@ pub trait UnreliablePolicy: Sized {
139139 fn handle ( overflow : & mut Self :: Overflow , message : Self ) -> bool ;
140140}
141141
142- struct ReliableMode ;
142+ mod mode {
143+ /// Uses a policy that always handles overflow messages.
144+ pub ( super ) struct Reliable ;
143145
144- struct UnreliableMode ;
146+ /// Uses a policy that may reject overflow messages.
147+ pub ( super ) struct Unreliable ;
148+ }
145149
146150trait Mode < T > : Sized {
151+ /// Overflow storage used by this mode.
147152 type Overflow : Overflow < T > ;
153+ /// Feedback returned from enqueue attempts.
148154 type Feedback ;
149155
156+ /// Updates overflow for a full inbox and reports whether the message was handled.
150157 fn handle ( overflow : & mut Self :: Overflow , message : T ) -> bool ;
158+ /// Maps ready-path feedback into this mode's feedback type.
151159 fn ready_feedback ( feedback : Feedback ) -> Self :: Feedback ;
160+ /// Maps overflow handling into this mode's feedback type.
152161 fn overflow_feedback ( handled : bool ) -> Self :: Feedback ;
162+ /// Returns `true` when this feedback should count as backoff.
153163 fn is_backoff ( feedback : & Self :: Feedback ) -> bool ;
164+ /// Returns `true` when this feedback means the receiver is closed.
154165 fn is_closed ( feedback : & Self :: Feedback ) -> bool ;
155166}
156167
157- impl < T : Policy > Mode < T > for ReliableMode {
168+ impl < T : Policy > Mode < T > for mode :: Reliable {
158169 type Overflow = T :: Overflow ;
159170 type Feedback = Feedback ;
160171
@@ -180,7 +191,7 @@ impl<T: Policy> Mode<T> for ReliableMode {
180191 }
181192}
182193
183- impl < T : UnreliablePolicy > Mode < T > for UnreliableMode {
194+ impl < T : UnreliablePolicy > Mode < T > for mode :: Unreliable {
184195 type Overflow = T :: Overflow ;
185196 type Feedback = Unreliable < Feedback > ;
186197
@@ -577,12 +588,12 @@ impl<T, M: Mode<T>> State<T, M> {
577588
578589/// Sender half of a mailbox.
579590pub struct Sender < T : Policy > {
580- state : Arc < State < T , ReliableMode > > ,
591+ state : Arc < State < T , mode :: Reliable > > ,
581592}
582593
583594/// Sender half of an unreliable mailbox.
584595pub struct UnreliableSender < T : UnreliablePolicy > {
585- state : Arc < State < T , UnreliableMode > > ,
596+ state : Arc < State < T , mode :: Unreliable > > ,
586597}
587598
588599impl < T : Policy > Clone for Sender < T > {
@@ -668,7 +679,7 @@ impl<T: UnreliablePolicy> UnreliableSender<T> {
668679/// Dropping the last sender disconnects the mailbox, but the receiver continues
669680/// returning buffered messages until ready and overflow are empty.
670681pub struct Receiver < T : Policy > {
671- state : Arc < State < T , ReliableMode > > ,
682+ state : Arc < State < T , mode :: Reliable > > ,
672683}
673684
674685/// Receiver half of an unreliable mailbox.
@@ -678,7 +689,7 @@ pub struct Receiver<T: Policy> {
678689/// Dropping the last sender disconnects the mailbox, but the receiver continues
679690/// returning buffered messages until ready and overflow are empty.
680691pub struct UnreliableReceiver < T : UnreliablePolicy > {
681- state : Arc < State < T , UnreliableMode > > ,
692+ state : Arc < State < T , mode :: Unreliable > > ,
682693}
683694
684695impl < T : Policy > Receiver < T > {
0 commit comments