[][src]Struct factory::SwappableFactory

pub struct SwappableFactory<T>(_);

#[cfg(feature = "swappable")] A Factory that allows for swapping inner factories dynamically.

This use a lock-free data structure for swapping.


use factory::{CloneFactory, Factory, SwappableFactory};

let f0 = SwappableFactory::new(CloneFactory::new(32));
let f1 = f0.clone();
assert_eq!(f0.create(), 32);
assert_eq!(f1.create(), 32);

assert_eq!(f0.create(), 50);
assert_eq!(f1.create(), 50);


impl<T: Factory> SwappableFactory<T>[src]

pub fn new(inner: T) -> Self[src]

Makes a new SwappableFactory with the initial inner factory.

pub fn get(&self) -> Arc<T>[src]

Returns the currently used factory.

pub fn swap(&self, new: T) -> Arc<T>[src]

Updates inner factory by new, and returns old one.

This operation affects all SwappableFactory instances cloned from the original one.

Trait Implementations

impl<T: Factory> Factory for SwappableFactory<T>[src]

type Item = T::Item

The type of instances created by this factory.

impl<T> Clone for SwappableFactory<T>[src]

default fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

impl<T: Default> Default for SwappableFactory<T>[src]

impl<T: Debug> Debug for SwappableFactory<T>[src]

Auto Trait Implementations

impl<T> Send for SwappableFactory<T> where
    T: Send + Sync

impl<T> Sync for SwappableFactory<T> where
    T: Send + Sync

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone

type Owned = T

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 

impl<T, U> TryFrom for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> BorrowMut for T where
    T: ?Sized

impl<T, U> TryInto for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.