Skip to main content

ToSql

Trait ToSql 

Source
pub trait ToSql {
    // Required methods
    fn to_sql(&self) -> Result<SqlValue, TypeError>;
    fn sql_type(&self) -> &'static str;

    // Provided method
    fn decimal_param_info(&self) -> Option<DecimalParamInfo> { ... }
}
Expand description

Trait for types that can be converted to SQL values.

This trait is implemented for common Rust types to enable type-safe parameter binding in queries.

Required Methods§

Source

fn to_sql(&self) -> Result<SqlValue, TypeError>

Convert this value to a SQL value.

Source

fn sql_type(&self) -> &'static str

Get the SQL type name for this value.

Provided Methods§

Source

fn decimal_param_info(&self) -> Option<DecimalParamInfo>

Explicit decimal precision and scale, when the value alone cannot convey it. None for every type except Numeric (created with numeric), which uses it to declare decimal(precision, scale) for an Always Encrypted column whose declared precision must match exactly.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ToSql for DateTime<FixedOffset>

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for DateTime<Utc>

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for Decimal

Available on crate feature decimal only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for NaiveDate

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for NaiveDateTime

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for NaiveTime

Available on crate feature chrono only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for String

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for Uuid

Available on crate feature uuid only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for Value

Available on crate feature json only.
Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for Vec<u8>

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for [u8]

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for bool

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for f32

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for f64

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for i16

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for i32

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for i64

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for str

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl ToSql for u8

Source§

fn to_sql(&self) -> Result<SqlValue, TypeError>

Source§

fn sql_type(&self) -> &'static str

Source§

impl<T: ToSql + ?Sized> ToSql for &T

Source§

impl<T: ToSql> ToSql for Option<T>

Implementors§

Source§

impl ToSql for Money

Available on crate feature decimal only.
Source§

impl ToSql for Numeric

Available on crate feature decimal only.
Source§

impl ToSql for SmallDateTime

Available on crate feature chrono only.
Source§

impl ToSql for SmallMoney

Available on crate feature decimal only.
Source§

impl ToSql for TypedNull