pub trait Connection:
Debug
+ Send
+ 'static {
// Required methods
fn exec<'life0, 'life1, 'async_trait>(
&'life0 mut self,
schema: &'life1 Arc<Schema>,
plan: Operation,
) -> Pin<Box<dyn Future<Output = Result<ExecResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn push_schema<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_schema: &'life1 Schema,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn applied_migrations<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AppliedMigration>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn apply_migration<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
id: u64,
name: &'life1 str,
migration: &'life2 Migration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
A live database session that can execute Operations.
Connections are obtained from Driver::connect and are managed by the
connection pool. All query execution flows through Connection::exec,
which accepts an Operation and returns an ExecResponse.
§Examples
use toasty_core::driver::{Connection, Operation, ExecResponse};
use toasty_core::driver::operation::Transaction;
// Execute a transaction start operation on a connection:
let response = conn.exec(&schema, Transaction::start().into()).await?;Required Methods§
Sourcefn exec<'life0, 'life1, 'async_trait>(
&'life0 mut self,
schema: &'life1 Arc<Schema>,
plan: Operation,
) -> Pin<Box<dyn Future<Output = Result<ExecResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exec<'life0, 'life1, 'async_trait>(
&'life0 mut self,
schema: &'life1 Arc<Schema>,
plan: Operation,
) -> Pin<Box<dyn Future<Output = Result<ExecResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes a database operation and returns the result.
This is the single entry point for all database interactions. The
query engine compiles user queries into Operation values and
dispatches them here. The driver translates each operation into
backend-specific calls and returns an ExecResponse.
Sourcefn push_schema<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_schema: &'life1 Schema,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn push_schema<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_schema: &'life1 Schema,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Creates tables and indices defined in the schema on the database. TODO: This will probably use database introspection in the future.
Sourcefn applied_migrations<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AppliedMigration>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn applied_migrations<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AppliedMigration>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns a list of currently applied database migrations.
Sourcefn apply_migration<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
id: u64,
name: &'life1 str,
migration: &'life2 Migration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn apply_migration<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
id: u64,
name: &'life1 str,
migration: &'life2 Migration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Applies a single migration to the database and records it as applied.