Struct lazy_pool::Pool[][src]

pub struct Pool<T> { /* fields omitted */ }

Implementations

impl<T> Pool<T>[src]

pub fn new(size: usize, factory: Box<dyn Fn() -> T + Send + Sync>) -> Self[src]

Default constructor for the Pool object:




let pool = Pool::new(10, Box::new(|| AnyObject));

The pool requires an object factory in order to be able to provide lazy initialization for objects.

pub fn get(&self) -> FuturePooled<T>

Notable traits for FuturePooled<T>

impl<T> Future for FuturePooled<T> type Output = Pooled<T>;
[src]

To get an object out of the pool use get. This will return a future so you either need to await on it or to use it in an async manner



let object = block_on(async { pool.get().await });

pub fn created(&self) -> usize[src]

Trait Implementations

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

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

Auto Trait Implementations

impl<T> RefUnwindSafe for Pool<T>

impl<T> Send for Pool<T> where
    T: Send

impl<T> Sync for Pool<T> where
    T: Send

impl<T> Unpin for Pool<T>

impl<T> UnwindSafe for Pool<T>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.