pub trait BlockingTxTrait<T: Send + 'static>:
Send
+ 'static
+ Debug
+ Display
+ AsRef<ChannelShared>
+ Sized {
// Required methods
fn send(&self, _item: T) -> Result<(), SendError<T>>;
fn try_send(&self, _item: T) -> Result<(), TrySendError<T>>;
fn send_timeout(
&self,
item: T,
timeout: Duration,
) -> Result<(), SendTimeoutError<T>>;
fn len(&self) -> usize;
fn capacity(&self) -> Option<usize>;
fn is_empty(&self) -> bool;
fn is_full(&self) -> bool;
fn clone_to_vec(self, count: usize) -> Vec<Self>;
// Provided method
fn is_disconnected(&self) -> bool { ... }
}
Expand description
For writing generic code with MTx & Tx
Required Methods§
Sourcefn send(&self, _item: T) -> Result<(), SendError<T>>
fn send(&self, _item: T) -> Result<(), SendError<T>>
Send message. Will block when channel is full.
Returns Ok(())
on successful.
Returns Err(SendError) when all Rx is dropped.
Sourcefn try_send(&self, _item: T) -> Result<(), TrySendError<T>>
fn try_send(&self, _item: T) -> Result<(), TrySendError<T>>
Try to send message, non-blocking
Returns Ok(())
when successful.
Returns Err(TrySendError::Full) on channel full for bounded channel.
Returns Err(TrySendError::Disconnected) when all Rx dropped.
Sourcefn send_timeout(
&self,
item: T,
timeout: Duration,
) -> Result<(), SendTimeoutError<T>>
fn send_timeout( &self, item: T, timeout: Duration, ) -> Result<(), SendTimeoutError<T>>
Waits for a message to be sent into the channel, but only for a limited time. Will block when channel is empty.
Returns Ok(())
when successful.
Returns Err(SendTimeoutError::Timeout) when the message could not be sent because the channel is full and the operation timed out.
Returns Err(SendTimeoutError::Disconnected) when all Rx dropped.
fn clone_to_vec(self, count: usize) -> Vec<Self>
Provided Methods§
Sourcefn is_disconnected(&self) -> bool
fn is_disconnected(&self) -> bool
Return true if the other side has closed
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.