Struct Builder

Source
pub struct Builder<M>{
    pub max_lifetime: Option<Duration>,
    pub idle_timeout: Option<Duration>,
    pub connection_timeout: Option<Duration>,
    pub max_size: u32,
    pub check_interval: Option<Duration>,
    /* private fields */
}
Expand description

A builder for a connection pool.

Fields§

§max_lifetime: Option<Duration>§idle_timeout: Option<Duration>§connection_timeout: Option<Duration>§max_size: u32§check_interval: Option<Duration>

Implementations§

Source§

impl<M> Builder<M>

Source

pub fn new() -> Self

Parameters are initialized with their default values.

Source

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

Sets the maximum lifetime of connections in the pool.

If a connection reaches its maximum lifetime while checked out it will be closed when it is returned to the pool.

Defaults to 30 minutes.

use default if max_lifetime is the zero Duration.

Source

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

Sets the idle timeout used by the pool.

If set, connections will be closed after exceed idle time.

Defaults to 3 minutes.

use default if idle_timeout is the zero Duration.

Source

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

Sets the connection timeout used by the pool.

Calls to Pool::get will wait this long for a connection to become available before returning an error.

Defaults to 3 seconds. don’t timeout if connection_timeout is the zero duration

Source

pub fn max_size(self, max_size: u32) -> Self

Sets the maximum number of connections managed by the pool.

Defaults to 10.

no limited if max_size is 0.

Source

pub fn check_interval(self, interval: Option<Duration>) -> Self

Sets the check interval of connections managed by the pool use the ManageConnection::check.

Defaults to 3s.

Source

pub fn build(&self, manager: M) -> Pool<M>

Consumes the builder, returning a new, initialized pool.

Trait Implementations§

Source§

impl<M> Debug for Builder<M>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<M> Default for Builder<M>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<M> Freeze for Builder<M>

§

impl<M> RefUnwindSafe for Builder<M>
where M: RefUnwindSafe,

§

impl<M> Send for Builder<M>

§

impl<M> Sync for Builder<M>

§

impl<M> Unpin for Builder<M>
where M: Unpin,

§

impl<M> UnwindSafe for Builder<M>
where M: UnwindSafe,

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.