[−][src]Struct factory::SwappableFactory
#[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.
fn create(&self) -> Self::Item
[src]
impl<T> Clone for SwappableFactory<T>
[src]
fn clone(&self) -> Self
[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]
fn default() -> SwappableFactory<T>
[src]
impl<T: Debug> Debug for SwappableFactory<T>
[src]
Auto Trait Implementations
impl<T> Send for SwappableFactory<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Sync for SwappableFactory<T> where
T: Send + Sync,
T: Send + Sync,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,