[−][src]Struct mobc::Builder
A builder for a connection pool.
Methods
impl<M> Builder<M> where
M: ConnectionManager,
[src]
M: ConnectionManager,
pub fn new() -> Self
[src]
Constructs a new Builder
.
Parameters are initialized with their default values.
pub fn max_size(self, max_size: u32) -> Self
[src]
Sets the maximum number of connections managed by the pool.
Defaults to 10.
Panics
Panics if max_size
is 0.
pub fn min_idle(self, min_idle: Option<u32>) -> Self
[src]
Sets the minimum idle connection count maintained by the pool.
If set, the pool will try to maintain at least this many idle
connections at all times, while respecting the value of max_size
.
Defaults to None
(equivalent to the value of max_size
).
pub fn max_lifetime(self, max_lifetime: Option<Duration>) -> Builder<M>
[src]
Sets the maximum lifetime of connections in the pool.
If set, connections will be closed after existing for at most 30 seconds beyond this duration.
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.
Panics
Panics if max_lifetime
is the zero Duration
.
pub fn idle_timeout(self, idle_timeout: Option<Duration>) -> Builder<M>
[src]
Sets the idle timeout used by the pool.
If set, connections will be closed after sitting idle for at most 30 seconds beyond this duration.
Defaults to 10 minutes.
Panics
Panics if idle_timeout
is the zero Duration
.
pub fn connection_timeout(self, connection_timeout: Duration) -> Builder<M>
[src]
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 30 seconds.
Panics
Panics if connection_timeout
is the zero duration
pub async fn build(self, manager: M) -> Result<Pool<M>, Error<M::Error>>
[src]
Consumes the builder, returning a new, initialized pool.
It will block until the pool has established its configured minimum number of connections, or it times out.
Errors
Returns an error if the pool is unable to open its minimum number of connections.
Panics
Panics if min_idle
is greater than max_size
.
pub async fn build_unchecked(self, manager: M) -> Pool<M>
[src]
Consumes the builder, returning a new pool.
Unlike build
, this method does not wait for any connections to be
established before returning.
Panics
Panics if min_idle
is greater than max_size
.
Trait Implementations
Auto Trait Implementations
impl<M> Send for Builder<M>
impl<M> Sync for Builder<M>
impl<M> Unpin for Builder<M> where
M: Unpin,
M: Unpin,
impl<M> UnwindSafe for Builder<M> where
M: UnwindSafe,
M: UnwindSafe,
impl<M> RefUnwindSafe for Builder<M> where
M: RefUnwindSafe,
M: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,