Struct sync_channel::Sender
source · pub struct Sender<T: Send, P: DeadlockPrevention = Spin> { /* private fields */ }
Expand description
The sender (transmit) side of a channel.
Implementations§
source§impl<T: Send, P: DeadlockPrevention> Sender<T, P>
impl<T: Send, P: DeadlockPrevention> Sender<T, P>
sourcepub fn send(&self, msg: T) -> Result<(), Error>
pub fn send(&self, msg: T) -> Result<(), Error>
Send a message, blocking until space in the channel’s buffer is available.
Returns Ok(())
if the message was sent successfully,
otherwise returns an Error
.
sourcepub fn send_buf(&self, buf: &[T]) -> Result<usize, Error>where
T: Copy,
pub fn send_buf(&self, buf: &[T]) -> Result<usize, Error>where T: Copy,
Sends a slice of objects through the channel, returning how many objects were sent.
This method only blocks on the first object being sent.
sourcepub fn send_all(&self, buf: &[T]) -> Result<(), Error>where
T: Copy,
pub fn send_all(&self, buf: &[T]) -> Result<(), Error>where T: Copy,
Attempts to send an entire slice of objects through the channel.
sourcepub fn try_send(&self, msg: T) -> Result<(), (T, Error)>
pub fn try_send(&self, msg: T) -> Result<(), (T, Error)>
Tries to send the message, only succeeding if buffer space is available.
If no buffer space is available, it returns the msg
with Error
back to the caller without blocking.
sourcepub fn try_send_buf(&self, buf: &[T]) -> Result<usize, Error>where
T: Copy,
pub fn try_send_buf(&self, buf: &[T]) -> Result<usize, Error>where T: Copy,
Sends a slice of objects through the channel, returning how many objects were sent.
This method does not block.
sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if the channel is disconnected.
Trait Implementations§
source§impl<T: Send, P: DeadlockPrevention> Clone for Sender<T, P>
impl<T: Send, P: DeadlockPrevention> Clone for Sender<T, P>
source§fn clone(&self) -> Self
fn clone(&self) -> Self
Clones this Sender
, returning another Sender
connected to the same channel.
This increments the channel’s sender count.
If there were previously no senders, the channel status is updated to Connected
.
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more