pub trait Db: Send + Sync {
// Required methods
fn dialect(&self) -> SqlDialect;
fn describe_table<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<DbTableDescriptor>, DbError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn exec<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [DbValue],
) -> Pin<Box<dyn Future<Output = Result<usize, DbError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [DbValue],
) -> Pin<Box<dyn Future<Output = Result<Vec<DbRow>, DbError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn new_batch(&self) -> Box<dyn DbBatch>;
}Expand description
A SQL backend: reads, one-off writes/DDL, and a factory for atomic batches.
Required Methods§
Sourcefn dialect(&self) -> SqlDialect
fn dialect(&self) -> SqlDialect
The SQL dialect this backend speaks (placeholder syntax, upsert verbs, type names). Synchronous: it’s pure metadata, no I/O.
Sourcefn describe_table<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<DbTableDescriptor>, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn describe_table<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<DbTableDescriptor>, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Introspect a table’s columns and primary key, or None if it does not
exist. Used for schema reconciliation before a batch is built.
Sourcefn exec<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [DbValue],
) -> Pin<Box<dyn Future<Output = Result<usize, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exec<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [DbValue],
) -> Pin<Box<dyn Future<Output = Result<usize, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a single statement outside any batch (autocommit). For DDL
(CREATE TABLE, ALTER TABLE ... ADD COLUMN) and one-off writes.
Returns the number of rows affected.
Sourcefn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [DbValue],
) -> Pin<Box<dyn Future<Output = Result<Vec<DbRow>, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [DbValue],
) -> Pin<Box<dyn Future<Output = Result<Vec<DbRow>, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run a read query and return every row. Materializes the full result set; not for unbounded scans.
Sourcefn new_batch(&self) -> Box<dyn DbBatch>
fn new_batch(&self) -> Box<dyn DbBatch>
Open a fresh, empty batch. Allocation only — no transaction is started
and nothing touches the backend until DbBatch::commit.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".