pub trait Driver:
Debug
+ Send
+ Sync
+ Sized {
type InternalDriver: Database;
// Required methods
fn identifier_delimiter() -> &'static str;
fn parameter_placeholder(index: usize) -> String;
async fn table_exists(
conn: &mut (impl EasyExecutor<Self> + Send + Sync),
name: &'static str,
) -> Result<bool>;
async fn create_table(
conn: &mut (impl EasyExecutor<Self> + Send + Sync),
table_name: &'static str,
fields: Vec<TableField>,
primary_keys: Vec<&'static str>,
foreign_keys: HashMap<&'static str, (Vec<&'static str>, Vec<&'static str>, bool)>,
) -> Result<()>;
}Expand description
Driver backend integration.
Implement this trait for custom drivers to describe the underlying sqlx::Database and
database-specific DDL helpers used by the macros and migrations.
Required Associated Types§
type InternalDriver: Database
Required Methods§
fn identifier_delimiter() -> &'static str
Sourcefn parameter_placeholder(index: usize) -> String
fn parameter_placeholder(index: usize) -> String
Build a parameter placeholder for the driver (index is 0-based).
async fn table_exists( conn: &mut (impl EasyExecutor<Self> + Send + Sync), name: &'static str, ) -> Result<bool>
Sourceasync fn create_table(
conn: &mut (impl EasyExecutor<Self> + Send + Sync),
table_name: &'static str,
fields: Vec<TableField>,
primary_keys: Vec<&'static str>,
foreign_keys: HashMap<&'static str, (Vec<&'static str>, Vec<&'static str>, bool)>,
) -> Result<()>
async fn create_table( conn: &mut (impl EasyExecutor<Self> + Send + Sync), table_name: &'static str, fields: Vec<TableField>, primary_keys: Vec<&'static str>, foreign_keys: HashMap<&'static str, (Vec<&'static str>, Vec<&'static str>, bool)>, ) -> Result<()>
Create a table with the provided schema metadata.
foreign_keys:
- Key: referenced table name
- Value: local field names, referenced field names, on delete/update cascade flag
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.