[−][src]Trait lifeline::Storage
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
Provided methods
fn clone_slot(res: &mut Option<Self>) -> Option<Self> where
Self: Clone,
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