pub struct Connector<DB>where
DB: Database,{ /* private fields */ }Expand description
Runs in the background, holds a copy of sqlx database connection Pool
created from the given [Handle], and closes the pooled connections once
the global AppContext is terminated.
In all fairness, this Connector does no “connecting” whatsoever: it
merely lazily initializes a Pool, holds a copy of it, and returns
another copy to the caller. All database connectivity logic is implemented
by the pool itself. The main purpose of this connector is to clean up during
AppSpindown.
Implementations§
Source§impl<DB> Connector<DB>where
DB: Database,
impl<DB> Connector<DB>where
DB: Database,
Sourcepub fn start<H>(handle: H) -> Pool<DB>where
H: Handle<Database = DB>,
pub fn start<H>(handle: H) -> Pool<DB>where
H: Handle<Database = DB>,
Creates a new Connector for the given [Handle] and sends it into
background to eventually close the pooled database connections once the
global AppContext is terminated.
The returned Pool may be cloned and re-used as necessary.
Auto Trait Implementations§
impl<DB> Freeze for Connector<DB>
impl<DB> !RefUnwindSafe for Connector<DB>
impl<DB> Send for Connector<DB>
impl<DB> Sync for Connector<DB>
impl<DB> Unpin for Connector<DB>
impl<DB> !UnwindSafe for Connector<DB>
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