pub trait Connection: Executor {
// Required methods
fn connect(
driver: &Self::Driver,
url: Cow<'static, str>,
) -> impl Future<Output = Result<<Self::Driver as Driver>::Connection>>
where Self: Sized;
fn begin(
&mut self,
) -> impl Future<Output = Result<<Self::Driver as Driver>::Transaction<'_>>>;
// Provided methods
fn sanitize_url(
_driver: &Self::Driver,
url: Cow<'static, str>,
) -> Result<Url>
where Self: Sized { ... }
fn disconnect(self) -> impl Future<Output = Result<()>>
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>>where
Self: Sized,
fn connect(
driver: &Self::Driver,
url: Cow<'static, str>,
) -> impl Future<Output = Result<<Self::Driver as Driver>::Connection>>where
Self: Sized,
Create a connection (or pool) to the given URL.
Implementations may perform I/O or validation during connect.
Callers should treat this as a potentially expensive operation.
Provided Methods§
fn sanitize_url(_driver: &Self::Driver, url: Cow<'static, str>) -> Result<Url>where
Self: Sized,
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.