pub trait RelationalBackend: Send + Sync {
type Tx<'a>: RelationalTx + 'a
where Self: 'a;
// Required methods
fn backend(&self) -> &str;
fn version(&self) -> &str;
fn dialect(&self) -> Dialect;
fn execute(
&self,
sql: &str,
params: &[Value],
) -> impl Future<Output = Result<u64, RelError>> + Send;
fn query(
&self,
sql: &str,
params: &[Value],
) -> impl Future<Output = Result<Vec<Row>, RelError>> + Send;
fn begin(
&self,
isolation: Isolation,
) -> impl Future<Output = Result<Self::Tx<'_>, RelError>> + Send;
// Provided methods
fn call_bound(&self) -> Option<Duration> { ... }
fn with_lock_held<'a>(
&'a self,
lock_sql: &'a str,
at_most: Duration,
during: Pin<Box<dyn Future<Output = ()> + Send + 'a>>,
) -> impl Future<Output = Result<(), RelError>> + Send { ... }
}Expand description
A relational database, as small as it can be.
Statements are written in the backend’s own Dialect; parameters are positional and written
as that dialect writes them ($1 for PostgreSQL). Nothing here translates SQL.
Required Associated Types§
Sourcetype Tx<'a>: RelationalTx + 'a
where
Self: 'a
type Tx<'a>: RelationalTx + 'a where Self: 'a
A transaction on this backend. Dropping it without commit rolls it back.
Required Methods§
Sourcefn execute(
&self,
sql: &str,
params: &[Value],
) -> impl Future<Output = Result<u64, RelError>> + Send
fn execute( &self, sql: &str, params: &[Value], ) -> impl Future<Output = Result<u64, RelError>> + Send
Run a statement that returns no rows; the result is the number of rows affected.
Provided Methods§
Sourcefn call_bound(&self) -> Option<Duration>
fn call_bound(&self) -> Option<Duration>
The per-call timeout this backend enforces, if one is configured; None (the default) means a
call waits as long as the server does. Every call that takes longer returns
RelError::Timeout.
Sourcefn with_lock_held<'a>(
&'a self,
lock_sql: &'a str,
at_most: Duration,
during: Pin<Box<dyn Future<Output = ()> + Send + 'a>>,
) -> impl Future<Output = Result<(), RelError>> + Send
fn with_lock_held<'a>( &'a self, lock_sql: &'a str, at_most: Duration, during: Pin<Box<dyn Future<Output = ()> + Send + 'a>>, ) -> impl Future<Output = Result<(), RelError>> + Send
Test support for kv.bounded_call: take lock_sql (a statement that locks a row) in a
transaction of its own, drive during while that lock is held, then roll back. during is
dropped, unfinished, after at_most, so a broken bound cannot hang the test. A backend that
enforces no bound returns RelError::Unsupported.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".