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.