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§
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 pool_init(&self, info: &PoolInitInfo) -> Value
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.
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.