@@ -64,8 +64,12 @@ pub struct Ref<'slot, T> {
64
64
new_state : usize ,
65
65
}
66
66
67
- /// Error returned when sending a message failed because a channel is at capacity.
68
- #[ derive( Eq , PartialEq ) ]
67
+ /// Error indicating that a `push` operation failed because a queue was at
68
+ /// capacity.
69
+ ///
70
+ /// This is returned by the [`ThingBuf::push`] and [`ThingBuf::push_ref`] (and
71
+ /// [`StaticThingBuf::push`]/[`StaticThingBuf::push_ref`]) methods.
72
+ #[ derive( PartialEq , Eq ) ]
69
73
pub struct Full < T = ( ) > ( T ) ;
70
74
71
75
/// State variables for the atomic ring buffer algorithm.
@@ -524,6 +528,18 @@ impl<T> Slot<T> {
524
528
525
529
unsafe impl < T : Sync > Sync for Slot < T > { }
526
530
531
+ // === impl Full ===
532
+
533
+ impl < T > Full < T > {
534
+ /// Unwraps the inner `T` value held by this error.
535
+ ///
536
+ /// This method allows recovering the original message when sending to a
537
+ /// channel has failed.
538
+ pub fn into_inner ( self ) -> T {
539
+ self . 0
540
+ }
541
+ }
542
+
527
543
impl < T > fmt:: Debug for Full < T > {
528
544
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
529
545
f. write_str ( "Full(..)" )
@@ -532,6 +548,9 @@ impl<T> fmt::Debug for Full<T> {
532
548
533
549
impl < T > fmt:: Display for Full < T > {
534
550
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
535
- f. write_str ( "channel full " )
551
+ f. write_str ( "queue at capacity " )
536
552
}
537
553
}
554
+
555
+ #[ cfg( feature = "std" ) ]
556
+ impl < T > std:: error:: Error for Full < T > { }
0 commit comments