DatabaseAdapter

Trait DatabaseAdapter 

Source
pub trait DatabaseAdapter {
    // Required methods
    fn name(&self) -> &'static str;
    fn dependencies(&self, db_type: DatabaseType) -> Vec<Dependency>;
    fn pool_type(&self, db_type: DatabaseType) -> &'static str;
    fn pool_init(&self, info: &PoolInitInfo) -> Value;
    fn imports(&self, db_type: DatabaseType) -> Vec<ImportSpec>;
    fn requires_async(&self, db_type: DatabaseType) -> bool;
}
Expand description

Trait for database adapters.

Implement this trait to support a specific database library (sqlx, diesel, etc.).

Required Methods§

Source

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

Adapter name for identification.

Source

fn dependencies(&self, db_type: DatabaseType) -> Vec<Dependency>

Dependencies required for a specific database type.

Source

fn pool_type(&self, db_type: DatabaseType) -> &'static str

The type name for a connection/pool.

Source

fn pool_init(&self, info: &PoolInitInfo) -> Value

Generate pool/connection initialization as a semantic Value.

Returns a Value that represents the initialization expression. The caller is responsible for rendering it with the appropriate language renderer.

Source

fn imports(&self, db_type: DatabaseType) -> Vec<ImportSpec>

Imports needed for database code.

Source

fn requires_async(&self, db_type: DatabaseType) -> bool

Whether this adapter requires async initialization.

Implementors§