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>

source

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.

source

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.

source

pub fn send_all(&self, buf: &[T]) -> Result<(), Error>where T: Copy,

Attempts to send an entire slice of objects through the channel.

source

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.

source

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.

source

pub fn is_disconnected(&self) -> bool

Returns true if the channel is disconnected.

source

pub fn receiver(&self) -> Receiver<T, P>

Obtain a Receiver endpoint connected to the same channel as this Sender.

Trait Implementations§

source§

impl<T: Send, P: DeadlockPrevention> Clone for Sender<T, P>

source§

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)

Performs copy-assignment from source. Read more
source§

impl<T: Send, P: DeadlockPrevention> Drop for Sender<T, P>

When the only remaining Sender is dropped, we mark the channel as disconnected and notify all of the Receivers

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T, P = Spin> !RefUnwindSafe for Sender<T, P>

§

impl<T, P> Send for Sender<T, P>where T: Sync,

§

impl<T, P> Sync for Sender<T, P>where T: Sync,

§

impl<T, P> Unpin for Sender<T, P>

§

impl<T, P = Spin> !UnwindSafe for Sender<T, P>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.