deadpool::managed

Struct PoolBuilder

source
pub struct PoolBuilder<M, W = Object<M>>
where M: Manager, W: From<Object<M>>,
{ /* private fields */ }
Expand description

Builder for Pools.

Instances of this are created by calling the Pool::builder() method.

Implementations§

source§

impl<M, W> PoolBuilder<M, W>
where M: Manager, W: From<Object<M>>,

source

pub fn build(self) -> Result<Pool<M, W>, BuildError>

Builds the Pool.

§Errors

See BuildError for details.

source

pub fn config(self, value: PoolConfig) -> Self

Sets a PoolConfig to build the Pool with.

source

pub fn max_size(self, value: usize) -> Self

source

pub fn timeouts(self, value: Timeouts) -> Self

source

pub fn wait_timeout(self, value: Option<Duration>) -> Self

Sets the Timeouts::wait value of the PoolConfig::timeouts.

source

pub fn create_timeout(self, value: Option<Duration>) -> Self

Sets the Timeouts::create value of the PoolConfig::timeouts.

source

pub fn recycle_timeout(self, value: Option<Duration>) -> Self

Sets the Timeouts::recycle value of the PoolConfig::timeouts.

source

pub fn queue_mode(self, value: QueueMode) -> Self

source

pub fn post_create(self, hook: impl Into<Hook<M>>) -> Self

Attaches a post_create hook.

The given hook will be called each time right after a new Object has been created.

source

pub fn pre_recycle(self, hook: impl Into<Hook<M>>) -> Self

Attaches a pre_recycle hook.

The given hook will be called each time right before an Object will be recycled.

source

pub fn post_recycle(self, hook: impl Into<Hook<M>>) -> Self

Attaches a post_recycle hook.

The given hook will be called each time right after an Object has been recycled.

source

pub fn runtime(self, value: Runtime) -> Self

Sets the Runtime.

§Important

The Runtime is optional. Most Pools don’t need a Runtime. If want to utilize timeouts, however a Runtime must be specified as you will otherwise get a PoolError::NoRuntimeSpecified when trying to use Pool::timeout_get().

PoolBuilder::build() will fail with a BuildError::NoRuntimeSpecified if you try to build a Pool with timeouts and no Runtime specified.

Trait Implementations§

source§

impl<M, W> Debug for PoolBuilder<M, W>
where M: Debug + Manager, W: From<Object<M>>,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M, W> Freeze for PoolBuilder<M, W>
where M: Freeze,

§

impl<M, W = Object<M>> !RefUnwindSafe for PoolBuilder<M, W>

§

impl<M, W> Send for PoolBuilder<M, W>

§

impl<M, W> Sync for PoolBuilder<M, W>

§

impl<M, W> Unpin for PoolBuilder<M, W>
where M: Unpin,

§

impl<M, W = Object<M>> !UnwindSafe for PoolBuilder<M, W>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

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

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.