Struct Channel
pub(crate) struct Channel<T> { pub(in ::sync::mpmc::zero) inner: Mutex<Inner>, pub(in ::sync::mpmc::zero) _marker: PhantomData<T> }
Zero-capacity channel.
Fields
inner: Mutex<Inner>Inner representation of the channel.
_marker: PhantomData<T>Indicates that dropping a
Channel<T>may drop values of typeT.
Implementations
impl<T> Channel<T>
fn new() -> SelfConstructs a new zero-capacity channel.
unsafe fn write(&self, token: &mut Token, msg: T) -> Result<(), T>Writes a message into the packet.
unsafe fn read(&self, token: &mut Token) -> Result<T, ()>Reads a message from the packet.
fn try_send(&self, msg: T) -> Result<(), TrySendError<T>>Attempts to send a message into the channel.
fn send(&self, msg: T, deadline: Option<Instant>) -> Result<(), SendTimeoutError<T>>Sends a message into the channel.
fn try_recv(&self) -> Result<T, TryRecvError>Attempts to receive a message without blocking.
fn recv(&self, deadline: Option<Instant>) -> Result<T, RecvTimeoutError>Receives a message from the channel.
fn disconnect(&self) -> boolDisconnects the channel and wakes up all blocked senders and receivers.
Returns
trueif this call disconnected the channel.fn len(&self) -> usizeReturns the current number of messages inside the channel.
fn capacity(&self) -> Option<usize>Returns the capacity of the channel.
fn is_empty(&self) -> boolReturns
trueif the channel is empty.fn is_full(&self) -> boolReturns
trueif the channel is full.fn is_disconnected(&self) -> boolReturns
trueif the channel is disconnected.
Auto Trait Implementations
impl<T> !Freeze for Channel<T>
impl<T> !Send for Channel<T>
impl<T> !Sync for Channel<T>
impl<T> RefUnwindSafe for Channel<T>
where
PhantomData<T>: RefUnwindSafe,
impl<T> Unpin for Channel<T>
where
PhantomData<T>: Unpin,
impl<T> UnsafeUnpin for Channel<T>
where
PhantomData<T>: UnsafeUnpin,
impl<T> UnwindSafe for Channel<T>
where
PhantomData<T>: UnwindSafe,
Blanket Implementations
impl<T> Any for Channel<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Channel<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Channel<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Channel<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for Channel<T>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for Channel<T>
impl<T, U> Into<U> for Channel<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Channel<T>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Channel<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>