OneshotStorage

Trait OneshotStorage 

Source
pub trait OneshotStorage:
    Send
    + Sync
    + Sized {
    type Value: Send;

    // Required methods
    fn new() -> Self;
    fn store(&self, value: Self::Value);
    fn try_take(&self) -> TakeResult<Self::Value>;
    fn is_sender_dropped(&self) -> bool;
    fn mark_sender_dropped(&self);
    fn is_receiver_closed(&self) -> bool;
    fn mark_receiver_closed(&self);
}
Expand description

Trait for oneshot value storage mechanisms

一次性值存储机制的 trait

Required Associated Types§

Source

type Value: Send

The value type that can be stored

Required Methods§

Source

fn new() -> Self

Create a new storage instance

Source

fn store(&self, value: Self::Value)

Store a value (called by sender)

Source

fn try_take(&self) -> TakeResult<Self::Value>

Try to take the stored value (called by receiver)

Source

fn is_sender_dropped(&self) -> bool

Check if the sender was dropped without sending

Source

fn mark_sender_dropped(&self)

Mark as sender dropped (called in Sender::drop)

Source

fn is_receiver_closed(&self) -> bool

Check if the receiver was closed

检查接收器是否已关闭

Source

fn mark_receiver_closed(&self)

Mark as receiver closed (called in Receiver::close)

标记接收器已关闭

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§