pub enum RecvError {
Disconnected,
Lagged {
skipped: usize,
},
}Expand description
Error returned by blocking recv operations.
§Variants
-
Disconnected: All senders have been dropped. For broadcast channels, this means no new messages will arrive. -
Lagged { skipped }: Only for bounded broadcast channels. Indicates that the receiver fell behind the sender(s) and missedskippedmessages. The receiver’s cursor has been advanced to the oldest available message.
§Lag Recovery
When Lagged { skipped } is encountered, the receiver has been automatically
advanced to the oldest message still in the ring buffer. Typical recovery patterns:
match rx.recv() {
Ok(msg) => process(msg),
Err(RecvError::Lagged { skipped }) => {
eprintln!("Fell behind by {} messages", skipped);
// Continue receiving: the next recv() will return the oldest
// available message, not an error.
}
Err(RecvError::Disconnected) => {
eprintln!("All senders disconnected");
break;
}
}To avoid lag:
- Ensure receiver threads wake promptly (use select! with short timeouts)
- Consider increasing broadcast channel capacity if lag is frequent
- Process messages quickly in the recv handler
Variants§
Trait Implementations§
impl Eq for RecvError
impl StructuralPartialEq for RecvError
Auto Trait Implementations§
impl Freeze for RecvError
impl RefUnwindSafe for RecvError
impl Send for RecvError
impl Sync for RecvError
impl Unpin for RecvError
impl UnsafeUnpin for RecvError
impl UnwindSafe for RecvError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more