pub struct PoolBuilder<M, W = 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>
impl<M, W> PoolBuilder<M, W>
Sourcepub fn config(self, value: PoolConfig) -> Self
pub fn config(self, value: PoolConfig) -> Self
Sets a PoolConfig to build the Pool with.
Sourcepub fn max_size(self, value: usize) -> Self
pub fn max_size(self, value: usize) -> Self
Sets the PoolConfig::max_size.
Sourcepub fn timeouts(self, value: Timeouts) -> Self
pub fn timeouts(self, value: Timeouts) -> Self
Sets the PoolConfig::timeouts.
Sourcepub fn wait_timeout(self, value: Option<Duration>) -> Self
pub fn wait_timeout(self, value: Option<Duration>) -> Self
Sets the Timeouts::wait value of the PoolConfig::timeouts.
Sourcepub fn create_timeout(self, value: Option<Duration>) -> Self
pub fn create_timeout(self, value: Option<Duration>) -> Self
Sets the Timeouts::create value of the PoolConfig::timeouts.
Sourcepub fn recycle_timeout(self, value: Option<Duration>) -> Self
pub fn recycle_timeout(self, value: Option<Duration>) -> Self
Sets the Timeouts::recycle value of the PoolConfig::timeouts.
Sourcepub fn post_create(self, hook: impl Into<Hook<M>>) -> Self
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.
Sourcepub fn pre_recycle(self, hook: impl Into<Hook<M>>) -> Self
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.
Sourcepub fn post_recycle(self, hook: impl Into<Hook<M>>) -> Self
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.
Sourcepub fn runtime(self, value: Runtime) -> Self
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.