pub struct Channel<S, R>(/* private fields */)
where
S: Serialize + DeserializeOwned,
R: Serialize + DeserializeOwned;Implementations§
Source§impl<S, R> Channel<S, R>
impl<S, R> Channel<S, R>
pub fn new_from_handle(handle: Handle) -> Channel<S, R>
Sourcepub fn create() -> Result<(Channel<S, R>, Handle), CreateChannelError>
pub fn create() -> Result<(Channel<S, R>, Handle), CreateChannelError>
Create a new channel. Returns one end as a Channel, and a Handle for the other end.
Generally, the handle is passed to another task.
pub fn send(&self, message: &S) -> Result<(), ChannelSendError>
Sourcepub fn try_receive(&self) -> Result<Option<R>, ChannelReceiveError>
pub fn try_receive(&self) -> Result<Option<R>, ChannelReceiveError>
Receive a message from the channel, if there’s one waiting. Returns Ok(None) if there are no pending
messages to be received.
Sourcepub fn receive_blocking(&self) -> Result<R, ChannelReceiveError>
pub fn receive_blocking(&self) -> Result<R, ChannelReceiveError>
Wait for a message to arrive via the channel.
pub fn receive( &self, ) -> impl Future<Output = Result<R, ChannelReceiveError>> + '_
Auto Trait Implementations§
impl<S, R> Freeze for Channel<S, R>
impl<S, R> RefUnwindSafe for Channel<S, R>where
S: RefUnwindSafe,
R: RefUnwindSafe,
impl<S, R> Send for Channel<S, R>
impl<S, R> Sync for Channel<S, R>
impl<S, R> Unpin for Channel<S, R>
impl<S, R> UnwindSafe for Channel<S, R>where
S: UnwindSafe,
R: UnwindSafe,
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be
further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<dyn Any>. Rc<dyn Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Anydyn Any. This is needed since Rust cannot
generate &Anydyn Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Anydyn Any. This is needed since Rust cannot
generate &mut dyn Any’s vtable from &mut Trait’s.