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§
Sourcefn dependencies(&self, db_type: DatabaseType) -> Vec<Dependency>
fn dependencies(&self, db_type: DatabaseType) -> Vec<Dependency>
Dependencies required for a specific database type.
Sourcefn pool_type(&self, db_type: DatabaseType) -> &'static str
fn pool_type(&self, db_type: DatabaseType) -> &'static str
The type name for a connection/pool.
Sourcefn generate_pool_init(&self, info: &PoolInitInfo) -> Vec<CodeFragment>
fn generate_pool_init(&self, info: &PoolInitInfo) -> Vec<CodeFragment>
Generate pool/connection initialization code.
Sourcefn generate_options(
&self,
info: &DatabaseOptionsInfo,
) -> Option<Vec<CodeFragment>>
fn generate_options( &self, info: &DatabaseOptionsInfo, ) -> Option<Vec<CodeFragment>>
Generate database-specific options (e.g., SQLite connect options).
Sourcefn imports(&self, db_type: DatabaseType) -> Vec<ImportSpec>
fn imports(&self, db_type: DatabaseType) -> Vec<ImportSpec>
Imports needed for database code.
Sourcefn requires_async(&self, db_type: DatabaseType) -> bool
fn requires_async(&self, db_type: DatabaseType) -> bool
Whether this adapter requires async initialization.