Struct lease::Pool[][src]

#[must_use]
pub struct Pool<T> { /* fields omitted */ }
Expand description

A pool of objects of type T that can be leased out.

This struct implements std::iter::FromIterator so you can create it from an iterator by calling std::iter::Iterator::collect()

Implementations

Creates a new Pool with an initial size of pool_size by calling init pool_size times.

Returns a future that resolves to a Lease when one is available

Tries to get a Lease if one is available. This function does not block.

Returns a struct that implements the futures_core::Stream trait.

Tries to get an existing Lease if available and if not returns a new one that has been added to the pool.

Calling this method repeatedly can cause the pool size to increase without bound.

Just like get_or_new() but caps the size of the pool. Once len() == cap then None is returned.

Returns the size of the pool

Sets the size of the pool to zero

This will disassociate all current Leasees and when they go out of scope the objects they’re holding will be dropped

Resizes the pool to pool_size

init is only called if the pool needs to grow.

Adds the Lease to this Pool if it isn’t already part of the pool.

Returns the number of currently available Leasees. Even if the return is non-zero calling get() immediately afterward can still fail if multiple.

Returns true if there are no items being stored.

Disassociates the returned [‘Lease’] from this Pool

Just like get_or_new() but uses Default::default() as the init function

Just like get_or_new_with_cap() but uses Default::default() as the init function

Just like resize() but uses Default::default() as the init function

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Creates a value from an iterator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.