pub struct Channel<T = ()> {
pub sender: Sender<T>,
pub receiver: Receiver<T>,
}
Expand description
Channel
struct that combines async_std::channel::Sender
and
async_std::channel::Receiver
into a single struct with sender
and receiver
members representing a single channel.
Fields§
§sender: Sender<T>
§receiver: Receiver<T>
Implementations§
Source§impl<T> Channel<T>
impl<T> Channel<T>
pub fn unbounded() -> Self
pub fn bounded(cap: usize) -> Self
pub fn oneshot() -> Self
pub fn drain(&self) -> Result<(), TryRecvError>
pub async fn recv(&self) -> Result<T, RecvError>
pub fn try_recv(&self) -> Result<T, TryRecvError>
pub async fn send(&self, msg: T) -> Result<(), SendError<T>>
pub fn try_send(&self, msg: T) -> Result<(), TrySendError<T>>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn receiver_count(&self) -> usize
pub fn sender_count(&self) -> usize
pub fn iter(&self) -> ChannelIterator<T> ⓘ
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Channel<T>
impl<T> RefUnwindSafe for Channel<T>
impl<T> Send for Channel<T>where
T: Send,
impl<T> Sync for Channel<T>where
T: Send,
impl<T = ()> !Unpin for Channel<T>
impl<T> UnwindSafe for Channel<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more