pub trait TypeMapping: Send + Sync {
// Required methods
fn rust_to_sql_type(&self, rust_type: &str) -> String;
fn sql_to_rust_type(&self, sql_type: &str) -> String;
fn default_value(&self, sql_type: &str) -> Option<String>;
fn supports_auto_increment(&self, sql_type: &str) -> bool;
fn max_string_length(&self, sql_type: &str) -> Option<usize>;
}Expand description
Type mapping trait for converting between Rust types and database-specific types
Required Methods§
Sourcefn rust_to_sql_type(&self, rust_type: &str) -> String
fn rust_to_sql_type(&self, rust_type: &str) -> String
Convert a Rust type to a database-specific column type
Sourcefn sql_to_rust_type(&self, sql_type: &str) -> String
fn sql_to_rust_type(&self, sql_type: &str) -> String
Convert a database-specific type to a Rust type
Sourcefn default_value(&self, sql_type: &str) -> Option<String>
fn default_value(&self, sql_type: &str) -> Option<String>
Get the default value for a type
Sourcefn supports_auto_increment(&self, sql_type: &str) -> bool
fn supports_auto_increment(&self, sql_type: &str) -> bool
Check if a type supports auto-increment
Sourcefn max_string_length(&self, sql_type: &str) -> Option<usize>
fn max_string_length(&self, sql_type: &str) -> Option<usize>
Get the maximum length for a string type
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".