Skip to main content

TypeMapping

Trait TypeMapping 

Source
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§

Source

fn rust_to_sql_type(&self, rust_type: &str) -> String

Convert a Rust type to a database-specific column type

Source

fn sql_to_rust_type(&self, sql_type: &str) -> String

Convert a database-specific type to a Rust type

Source

fn default_value(&self, sql_type: &str) -> Option<String>

Get the default value for a type

Source

fn supports_auto_increment(&self, sql_type: &str) -> bool

Check if a type supports auto-increment

Source

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".

Implementors§