pub trait Channel<T>: Send + Sync {
Show 13 methods
// Required methods
fn send(&self, value: T) -> Result<(), ChannelError>;
fn try_send(&self, value: T) -> Result<(), ChannelError>;
fn recv(&self) -> Result<T, ChannelError>;
fn try_recv(&self) -> Result<T, ChannelError>;
fn is_empty(&self) -> bool;
fn is_full(&self) -> bool;
fn capacity(&self) -> Option<usize>;
// Provided methods
fn send_batch(&self, values: Vec<T>) -> Result<usize, ChannelError> { ... }
fn recv_batch(&self, max_count: usize) -> Vec<T> { ... }
fn close(&self) { ... }
fn is_closed(&self) -> bool { ... }
fn len(&self) -> usize { ... }
fn stats(&self) -> Option<ChannelStatistics> { ... }
}Expand description
Trait for unified channel behavior following Interface Segregation Principle
Required Methods§
Sourcefn send(&self, value: T) -> Result<(), ChannelError>
fn send(&self, value: T) -> Result<(), ChannelError>
Send a value, blocking if necessary
Sourcefn try_send(&self, value: T) -> Result<(), ChannelError>
fn try_send(&self, value: T) -> Result<(), ChannelError>
Try to send without blocking
Sourcefn recv(&self) -> Result<T, ChannelError>
fn recv(&self) -> Result<T, ChannelError>
Receive a value, blocking if necessary
Sourcefn try_recv(&self) -> Result<T, ChannelError>
fn try_recv(&self) -> Result<T, ChannelError>
Try to receive without blocking
Provided Methods§
Sourcefn send_batch(&self, values: Vec<T>) -> Result<usize, ChannelError>
fn send_batch(&self, values: Vec<T>) -> Result<usize, ChannelError>
Send multiple values in batch. Default sends each individually.
Sourcefn recv_batch(&self, max_count: usize) -> Vec<T>
fn recv_batch(&self, max_count: usize) -> Vec<T>
Receive up to max_count values in batch. Default receives individually.
Sourcefn stats(&self) -> Option<ChannelStatistics>
fn stats(&self) -> Option<ChannelStatistics>
Return statistics if the channel tracks them.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".