Driver

Trait Driver 

Source
pub trait Driver:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn url(&self) -> Cow<'_, str>;
    fn capability(&self) -> &'static Capability;
    fn connect<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Connection>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn generate_migration(&self, schema_diff: &SchemaDiff<'_>) -> Migration;
    fn reset_db<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn max_connections(&self) -> Option<usize> { ... }
}

Required Methods§

Source

fn url(&self) -> Cow<'_, str>

Returns the URL this driver is connecting to.

Source

fn capability(&self) -> &'static Capability

Describes the driver’s capability, which informs the query planner.

Source

fn connect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Connection>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a new connection to the database.

This method is called by the [Pool] whenever a Connection is requested while none is available and there is room to create a new Connection.

Source

fn generate_migration(&self, schema_diff: &SchemaDiff<'_>) -> Migration

Generates a migration from a SchemaDiff.

Source

fn reset_db<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Drops the entire database and recreates an empty one without applying migrations.

Provided Methods§

Source

fn max_connections(&self) -> Option<usize>

Returns the maximum number of simultaneous database connections supported. For example, this is Some(1) for the in-memory SQLite driver which cannot be pooled.

Implementors§