pub enum DatabaseConnection {
SqlxMySqlPoolConnection(SqlxMySqlPoolConnection),
Disconnected,
}
Expand description
Handle a database connection depending on the backend enabled by the feature flags. This creates a database pool.
Variants
SqlxMySqlPoolConnection(SqlxMySqlPoolConnection)
Create a MYSQL database connection and pool
Disconnected
The connection to the database has been severed
Implementations
impl DatabaseConnection
impl DatabaseConnection
pub fn set_metric_callback<F>(&mut self, _callback: F) where
F: 'static + Fn(&Info<'_>) + Send + Sync,
pub fn set_metric_callback<F>(&mut self, _callback: F) where
F: 'static + Fn(&Info<'_>) + Send + Sync,
Sets a callback to metric this connection
Trait Implementations
impl Clone for DatabaseConnection
impl Clone for DatabaseConnection
fn clone(&self) -> DatabaseConnection
fn clone(&self) -> DatabaseConnection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl ConnectionTrait for DatabaseConnection
impl ConnectionTrait for DatabaseConnection
fn get_database_backend(&self) -> DatabaseBackend
fn get_database_backend(&self) -> DatabaseBackend
fn execute<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
DatabaseConnection: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
DatabaseConnection: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Execute a Statement
fn query_one<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
DatabaseConnection: 'async_trait,
fn query_one<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
DatabaseConnection: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Execute a Statement and return a query
fn query_all<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult, Global>, DbErr>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
DatabaseConnection: 'async_trait,
fn query_all<'life0, 'async_trait>(
&'life0 self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult, Global>, DbErr>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
DatabaseConnection: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Execute a Statement and return a collection Vec<QueryResult> on success
fn support_returning(&self) -> bool
fn support_returning(&self) -> bool
Check if the connection supports RETURNING
syntax on insert and update
fn is_mock_connection(&self) -> bool
fn is_mock_connection(&self) -> bool
Check if the connection is a test connection for the Mock database
impl Debug for DatabaseConnection
impl Debug for DatabaseConnection
impl Default for DatabaseConnection
impl Default for DatabaseConnection
fn default() -> DatabaseConnection
fn default() -> DatabaseConnection
Returns the “default value” for a type. Read more
impl<'a> StreamTrait<'a> for DatabaseConnection
impl<'a> StreamTrait<'a> for DatabaseConnection
type Stream = QueryStream
type Stream = QueryStream
Create a stream for the QueryResult
fn stream(
&'a self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<<DatabaseConnection as StreamTrait<'a>>::Stream, DbErr>> + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
fn stream(
&'a self,
stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<<DatabaseConnection as StreamTrait<'a>>::Stream, DbErr>> + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Execute a Statement and return a stream of results
impl TransactionTrait for DatabaseConnection
impl TransactionTrait for DatabaseConnection
fn transaction<'life0, 'async_trait, F, T, E>(
&'life0 self,
_callback: F
) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
F: for<'c> FnOnce(&'c DatabaseTransaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c, Global>> + Send + 'async_trait,
T: Send + 'async_trait,
E: Error + Send + 'async_trait,
DatabaseConnection: 'async_trait,
fn transaction<'life0, 'async_trait, F, T, E>(
&'life0 self,
_callback: F
) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
F: for<'c> FnOnce(&'c DatabaseTransaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c, Global>> + Send + 'async_trait,
T: Send + 'async_trait,
E: Error + Send + 'async_trait,
DatabaseConnection: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Execute the function inside a transaction. If the function returns an error, the transaction will be rolled back. If it does not return an error, the transaction will be committed.
fn begin<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<DatabaseTransaction, DbErr>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
DatabaseConnection: 'async_trait,
fn begin<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<DatabaseTransaction, DbErr>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
DatabaseConnection: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Execute SQL BEGIN
transaction.
Returns a Transaction that can be committed or rolled back Read more
Auto Trait Implementations
impl !RefUnwindSafe for DatabaseConnection
impl Send for DatabaseConnection
impl Sync for DatabaseConnection
impl Unpin for DatabaseConnection
impl !UnwindSafe for DatabaseConnection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more