pub struct DatabaseBuilder { /* private fields */ }Expand description
A builder for creating a Database connection with custom options.
Allows configuration of connection pool settings such as maximum connections, timeouts, and lifetimes.
§Example
ⓘ
let db = Database::builder()
.max_connections(10)
.min_connections(2)
.acquire_timeout(std::time::Duration::from_secs(5))
.connect("postgres://...")
.await?;Implementations§
Source§impl DatabaseBuilder
impl DatabaseBuilder
Sourcepub fn max_connections(self, max: u32) -> Self
pub fn max_connections(self, max: u32) -> Self
Sets the maximum number of connections that this pool should maintain.
Sourcepub fn min_connections(self, min: u32) -> Self
pub fn min_connections(self, min: u32) -> Self
Sets the minimum number of connections that this pool should maintain.
Sourcepub fn acquire_timeout(self, timeout: Duration) -> Self
pub fn acquire_timeout(self, timeout: Duration) -> Self
Sets the maximum amount of time to spend waiting for a connection.
Sourcepub fn idle_timeout(self, timeout: Duration) -> Self
pub fn idle_timeout(self, timeout: Duration) -> Self
Sets the maximum amount of time a connection may be idle.
Sourcepub fn max_lifetime(self, lifetime: Duration) -> Self
pub fn max_lifetime(self, lifetime: Duration) -> Self
Sets the maximum lifetime of a connection.
Auto Trait Implementations§
impl Freeze for DatabaseBuilder
impl !RefUnwindSafe for DatabaseBuilder
impl Send for DatabaseBuilder
impl Sync for DatabaseBuilder
impl Unpin for DatabaseBuilder
impl !UnwindSafe for DatabaseBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more