Skip to main content

Driver

Trait Driver 

Source
pub trait Driver:
    Default
    + Clone
    + Sync
    + Send
    + Debug {
    type Connection: Connection<Driver = Self> + Debug;
    type SqlWriter: SqlWriter;
    type Prepared: Prepared;
    type Transaction<'c>: Transaction<'c>;

    const NAME: &'static [&'static str];

    // Required method
    fn sql_writer(&self) -> Self::SqlWriter;

    // Provided methods
    fn name(&self) -> &'static str { ... }
    fn connect_pool(
        &self,
        url: Cow<'static, str>,
        config: PoolConfig,
    ) -> impl Future<Output = Result<impl ConnectionPool<Self>>> + Send { ... }
}
Expand description

Backend connector and dialect.

Required Associated Constants§

Source

const NAME: &'static [&'static str]

Human-readable backend name.

Required Associated Types§

Source

type Connection: Connection<Driver = Self> + Debug

Concrete connection type.

Source

type SqlWriter: SqlWriter

Dialect-specific SQL writer.

Source

type Prepared: Prepared

Prepared statement implementation.

Source

type Transaction<'c>: Transaction<'c>

Transaction implementation.

Required Methods§

Source

fn sql_writer(&self) -> Self::SqlWriter

Returns a dialect-specific SQL writer for query construction.

Provided Methods§

Source

fn name(&self) -> &'static str

Returns the primary name of the driver.

Source

fn connect_pool( &self, url: Cow<'static, str>, config: PoolConfig, ) -> impl Future<Output = Result<impl ConnectionPool<Self>>> + Send

Creates a new connection to the database at the specified URL.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§