[][src]Trait lifeline::Storage

pub trait Storage: Sized + 'static {
    fn take_or_clone(res: &mut Option<Self>) -> Option<Self>;

    fn clone_slot(res: &mut Option<Self>) -> Option<Self>
    where
        Self: Clone
, { ... }
fn take_slot(res: &mut Option<Self>) -> Option<Self> { ... } }

Defines a resource (or channel endpoint) which can be stored on the bus, and how it is taken or cloned.

Lifeline provides helper macros which can implement the Clone or Take operations: impl_storage_take!(Struct), and impl_storage_clone!(Struct)

Resource Example

use lifeline::impl_storage_clone;

#[derive(Debug, Clone)]
struct ExampleConfiguration {
    value: bool
}

impl_storage_clone!(ExampleConfiguration);

Channel Example

Lifeline also provides impl_channel_take!(Struct<T>) and impl_channel_clone!(Struct<T>), which configure the generic bounds required for a channel implementation:

use lifeline::impl_channel_take;
use std::marker::PhantomData;

#[derive(Debug)]
struct ExampleSender<T> {
    _t: PhantomData<T>
}

impl_channel_take!(ExampleSender<T>);

Required methods

fn take_or_clone(res: &mut Option<Self>) -> Option<Self>

If Self::Tx implements clone, clone it. Otherwise use Option::take

Loading content...

Provided methods

fn clone_slot(res: &mut Option<Self>) -> Option<Self> where
    Self: Clone

Helper which clones the provided option, requiring that Self: Clone

fn take_slot(res: &mut Option<Self>) -> Option<Self>

Helper which takes the provided option, returning None if it's already been taken

Loading content...

Implementations on Foreign Types

impl<T: Send + 'static> Storage for Sender<T>[src]

impl<T: Send + 'static> Storage for Receiver<T>[src]

impl<T: Send + 'static> Storage for Sender<T>[src]

impl<T: Send + 'static> Storage for Receiver<T>[src]

impl<T: Send + 'static> Storage for Sender<T>[src]

impl<T: Send + 'static> Storage for Receiver<T>[src]

impl<T: Send + 'static> Storage for Sender<T>[src]

impl<T: Send + 'static> Storage for Receiver<T>[src]

Loading content...

Implementors

impl<T: Send + 'static> Storage for lifeline::subscription::Receiver<T>[src]

impl<T: Send + 'static> Storage for lifeline::subscription::Sender<T>[src]

Loading content...