pub trait Connection: Executor {
// Required methods
fn connect(
driver: &Self::Driver,
url: Cow<'static, str>,
) -> impl Future<Output = Result<<Self::Driver as Driver>::Connection>> + Send
where Self: Sized;
fn begin(
&mut self,
) -> impl Future<Output = Result<<Self::Driver as Driver>::Transaction<'_>>> + Send;
// Provided methods
fn sanitize_url(
driver: &Self::Driver,
url: Cow<'static, str>,
) -> Result<Url>
where Self: Sized { ... }
fn disconnect(self) -> impl Future<Output = Result<()>> + Send
where Self: Sized { ... }
}Expand description
A live database handle capable of executing queries and spawning transactions.
Extends Executor with connection and transaction management.
§Lifecycle
connectcreates (or fetches) an underlying connection. It may eagerly establish network I/O; always await it.beginstarts a transaction scope. Commit/rollback MUST be awaited to guarantee resource release.
Required Methods§
Sourcefn connect(
driver: &Self::Driver,
url: Cow<'static, str>,
) -> impl Future<Output = Result<<Self::Driver as Driver>::Connection>> + Sendwhere
Self: Sized,
fn connect(
driver: &Self::Driver,
url: Cow<'static, str>,
) -> impl Future<Output = Result<<Self::Driver as Driver>::Connection>> + Sendwhere
Self: Sized,
Establishes a connection (or pool) to the database specified by the URL.
Implementations may perform I/O or validation during connect.
Callers should treat this as a potentially expensive operation.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".