pub trait Database: Database {
const SYSTEM: &'static str;
// Required methods
fn connection_attributes(
pool: &Pool<Self>,
) -> (Option<String>, Option<u16>, Option<String>);
fn rows_affected(result: &<Self as Database>::QueryResult) -> u64;
}Expand description
Per-backend contract providing the database system name and a method to extract connection-level attributes from the backend’s connect options.
Each supported SQLx backend (Postgres, Sqlite, Mysql) implements this trait behind its
corresponding feature flag. The trait is intentionally minimal – it exists solely to
let the generic wrapper types resolve connection attributes once at pool construction
time.
Required Associated Constants§
Required Methods§
Sourcefn connection_attributes(
pool: &Pool<Self>,
) -> (Option<String>, Option<u16>, Option<String>)
fn connection_attributes( pool: &Pool<Self>, ) -> (Option<String>, Option<u16>, Option<String>)
Extract host, port, and database namespace from the backend’s connect options.
Returns (host, port, namespace) where any component may be None if the backend
does not support it (e.g. Sqlite has no host or port).
Sourcefn rows_affected(result: &<Self as Database>::QueryResult) -> u64
fn rows_affected(result: &<Self as Database>::QueryResult) -> u64
Extract the number of rows affected from a QueryResult.
Each SQLx backend defines its own QueryResult type with an inherent
rows_affected() method. This trait method provides a uniform interface for the
instrumentation layer.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.