Trait DataKey

Source
pub trait DataKey {
    type Value: Clone + 'static;

    // Required methods
    async fn init();
    async fn on_change();
    async fn on_drop();
    fn try_read() -> Option<impl Deref<Target = Self::Value>>;
    fn try_peek() -> Option<impl Deref<Target = Self::Value>>;
    fn try_write() -> Option<impl DerefMut<Target = Self::Value>>;

    // Provided methods
    fn read() -> impl Deref<Target = Self::Value> { ... }
    fn peek() -> impl Deref<Target = Self::Value> { ... }
    fn write() -> impl DerefMut<Target = Self::Value> { ... }
}

Required Associated Types§

Source

type Value: Clone + 'static

Required Methods§

Source

async fn init()

Source

async fn on_change()

Source

async fn on_drop()

Source

fn try_read() -> Option<impl Deref<Target = Self::Value>>

Source

fn try_peek() -> Option<impl Deref<Target = Self::Value>>

Source

fn try_write() -> Option<impl DerefMut<Target = Self::Value>>

Provided Methods§

Source

fn read() -> impl Deref<Target = Self::Value>

Source

fn peek() -> impl Deref<Target = Self::Value>

Source

fn write() -> impl DerefMut<Target = Self::Value>

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§