Trait AnyConnectionBackend

Source
pub trait AnyConnectionBackend:
    Any
    + Debug
    + Send
    + 'static {
Show 17 methods // Required methods fn name(&self) -> &str; fn close(self: Box<Self>) -> BoxFuture<'static, Result<()>>; fn ping(&mut self) -> BoxFuture<'_, Result<()>>; fn begin( &mut self, statement: Option<Cow<'static, str>>, ) -> BoxFuture<'_, Result<()>>; fn commit(&mut self) -> BoxFuture<'_, Result<()>>; fn rollback(&mut self) -> BoxFuture<'_, Result<()>>; fn start_rollback(&mut self); fn shrink_buffers(&mut self); fn fetch_many<'q>( &'q mut self, query: &'q str, persistent: bool, arguments: Option<AnyArguments<'q>>, ) -> BoxStream<'q, Result<Either<AnyQueryResult, AnyRow>>>; fn fetch_optional<'q>( &'q mut self, query: &'q str, persistent: bool, arguments: Option<AnyArguments<'q>>, ) -> BoxFuture<'q, Result<Option<AnyRow>>>; fn prepare_with<'c, 'q: 'c>( &'c mut self, sql: &'q str, parameters: &[AnyTypeInfo], ) -> BoxFuture<'c, Result<AnyStatement<'q>>>; fn describe<'q>( &'q mut self, sql: &'q str, ) -> BoxFuture<'q, Result<Describe<Any>>>; // Provided methods fn get_transaction_depth(&self) -> usize { ... } fn is_in_transaction(&self) -> bool { ... } fn cached_statements_size(&self) -> usize { ... } fn clear_cached_statements(&mut self) -> BoxFuture<'_, Result<()>> { ... } fn as_migrate(&mut self) -> Result<&mut (dyn Migrate + Send + 'static)> { ... }
}

Required Methods§

Source

fn name(&self) -> &str

The backend name.

Source

fn close(self: Box<Self>) -> BoxFuture<'static, Result<()>>

Explicitly close this database connection.

This method is not required for safe and consistent operation. However, it is recommended to call it instead of letting a connection drop as the database backend will be faster at cleaning up resources.

Source

fn ping(&mut self) -> BoxFuture<'_, Result<()>>

Checks if a connection to the database is still valid.

Source

fn begin( &mut self, statement: Option<Cow<'static, str>>, ) -> BoxFuture<'_, Result<()>>

Begin a new transaction or establish a savepoint within the active transaction.

If this is a new transaction, statement may be used instead of the default “BEGIN” statement.

If we are already inside a transaction and statement.is_some(), then Error::InvalidSavePoint is returned without running any statements.

Source

fn commit(&mut self) -> BoxFuture<'_, Result<()>>

Source

fn rollback(&mut self) -> BoxFuture<'_, Result<()>>

Source

fn start_rollback(&mut self)

Source

fn shrink_buffers(&mut self)

Source

fn fetch_many<'q>( &'q mut self, query: &'q str, persistent: bool, arguments: Option<AnyArguments<'q>>, ) -> BoxStream<'q, Result<Either<AnyQueryResult, AnyRow>>>

Source

fn fetch_optional<'q>( &'q mut self, query: &'q str, persistent: bool, arguments: Option<AnyArguments<'q>>, ) -> BoxFuture<'q, Result<Option<AnyRow>>>

Source

fn prepare_with<'c, 'q: 'c>( &'c mut self, sql: &'q str, parameters: &[AnyTypeInfo], ) -> BoxFuture<'c, Result<AnyStatement<'q>>>

Source

fn describe<'q>( &'q mut self, sql: &'q str, ) -> BoxFuture<'q, Result<Describe<Any>>>

Provided Methods§

Source

fn get_transaction_depth(&self) -> usize

Returns the current transaction depth.

Transaction depth indicates the level of nested transactions:

  • Level 0: No active transaction.
  • Level 1: A transaction is active.
  • Level 2 or higher: A transaction is active and one or more SAVEPOINTs have been created within it.
Source

fn is_in_transaction(&self) -> bool

Checks if the connection is currently in a transaction.

This method returns true if the current transaction depth is greater than 0, indicating that a transaction is active. It returns false if the transaction depth is 0, meaning no transaction is active.

Source

fn cached_statements_size(&self) -> usize

The number of statements currently cached in the connection.

Source

fn clear_cached_statements(&mut self) -> BoxFuture<'_, Result<()>>

Removes all statements from the cache, closing them on the server if needed.

Source

fn as_migrate(&mut self) -> Result<&mut (dyn Migrate + Send + 'static)>

Implementors§