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 generate_pool_init(&self, info: &PoolInitInfo) -> Vec<CodeFragment>;
    fn generate_options(
        &self,
        info: &DatabaseOptionsInfo,
    ) -> Option<Vec<CodeFragment>>;
    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 generate_pool_init(&self, info: &PoolInitInfo) -> Vec<CodeFragment>

Generate pool/connection initialization code.

Source

fn generate_options( &self, info: &DatabaseOptionsInfo, ) -> Option<Vec<CodeFragment>>

Generate database-specific options (e.g., SQLite connect options).

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§