pub trait DatabaseAdapter: Send + Sync {
// Required methods
fn inspector(&self) -> Box<dyn SchemaInspector>;
fn migration_runner(&self) -> Box<dyn MigrationRunner>;
fn database_type(&self) -> &str;
fn test_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Main database adapter trait
This is the entry point for database operations. It provides:
- Connection management
- Factory methods for inspectors and runners
- Database-specific configuration
Each database type (PostgreSQL, MySQL, etc.) implements this trait.
Required Methods§
Sourcefn inspector(&self) -> Box<dyn SchemaInspector>
fn inspector(&self) -> Box<dyn SchemaInspector>
Get a schema inspector for this database
The inspector is used for read-only schema introspection.
Sourcefn migration_runner(&self) -> Box<dyn MigrationRunner>
fn migration_runner(&self) -> Box<dyn MigrationRunner>
Get a migration runner for this database
The runner is used for executing schema changes.
Sourcefn database_type(&self) -> &str
fn database_type(&self) -> &str
Get the database type identifier
Returns a string like “postgresql”, “mysql”, “sqlite”, etc.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".