pub struct Receiver<S: OneshotStorage> { /* private fields */ }Expand description
Receiver for one-shot value transfer
Implements Future directly for .await usage.
一次性值传递的接收器
直接实现了 Future,可直接使用 .await
Implementations§
Source§impl<S: OneshotStorage> Receiver<S>
impl<S: OneshotStorage> Receiver<S>
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Close the receiver, preventing any future messages from being sent.
Any send operation which happens after this method returns is guaranteed
to fail. After calling close, try_recv should be called to receive
a value if one was sent before the call to close completed.
关闭接收器,阻止任何将来的消息发送。
在此方法返回后发生的任何 send 操作都保证失败。
调用 close 后,应调用 try_recv 来接收在 close 完成之前发送的值。
Sourcepub fn blocking_recv(self) -> Result<S::Value, RecvError>
pub fn blocking_recv(self) -> Result<S::Value, RecvError>
Source§impl<T: Send> Receiver<GenericStorage<T>>
impl<T: Send> Receiver<GenericStorage<T>>
Sourcepub fn try_recv(&mut self) -> Result<T, TryRecvError>
pub fn try_recv(&mut self) -> Result<T, TryRecvError>
Try to receive a value without blocking
Returns Ok(value) if value is ready, Err(TryRecvError::Empty) if pending,
or Err(TryRecvError::Closed) if sender was dropped.
尝试接收值而不阻塞
如果值就绪返回 Ok(value),如果待处理返回 Err(TryRecvError::Empty),
如果发送器被丢弃返回 Err(TryRecvError::Closed)
Source§impl<S: State> Receiver<LiteStorage<S>>
impl<S: State> Receiver<LiteStorage<S>>
Sourcepub async fn recv(self) -> Result<S, RecvError>
pub async fn recv(self) -> Result<S, RecvError>
Receive a value asynchronously
This is equivalent to using .await directly on the receiver
异步接收一个值
这等同于直接在 receiver 上使用 .await
Sourcepub fn try_recv(&mut self) -> Result<S, TryRecvError>
pub fn try_recv(&mut self) -> Result<S, TryRecvError>
Try to receive a value without blocking
Returns Ok(value) if value is ready, Err(TryRecvError::Empty) if pending,
or Err(TryRecvError::Closed) if sender was dropped.
尝试接收值而不阻塞
如果值就绪返回 Ok(value),如果待处理返回 Err(TryRecvError::Empty),
如果发送器被丢弃返回 Err(TryRecvError::Closed)