[][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.

Examples

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);

f0.swap(CloneFactory::new(50));
assert_eq!(f0.create(), 50);
assert_eq!(f1.create(), 50);

Methods

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)
1.0.0
[src]

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
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

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

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.