Trait tiberius::ToSql

source ·
pub trait ToSql: Send + Sync {
    // Required method
    fn to_sql(&self) -> ColumnData<'_>;
}
Expand description

A conversion trait to a TDS type.

A ToSql implementation for a Rust type is needed for using it as a parameter in the Client#query or Client#execute methods. The following Rust types are already implemented to match the given server types:

Rust typeServer type
u8tinyint
i16smallint
i32int
i64bigint
f32float(24)
f64float(53)
boolbit
String/&str (< 4000 characters)nvarchar(4000)
String/&strnvarchar(max)
Vec<u8>/&[u8] (< 8000 bytes)varbinary(8000)
Vec<u8>/&[u8]varbinary(max)
Uuiduniqueidentifier
Numericnumeric/decimal
Decimal (with feature flag rust_decimal)numeric/decimal
BigDecimal (with feature flag bigdecimal)numeric/decimal
XmlDataxml
NaiveDate (with chrono feature, TDS 7.3 >)date
NaiveTime (with chrono feature, TDS 7.3 >)time
DateTime (with chrono feature, TDS 7.3 >)datetimeoffset
NaiveDateTime (with chrono feature, TDS 7.3 >)datetime2
NaiveDateTime (with chrono feature, TDS 7.2)datetime

It is possible to use some of the types to write into columns that are not of the same type. For example on systems following the TDS 7.3 standard (SQL Server 2008 and later), the chrono type NaiveDateTime can also be used to write to datetime, datetime2 and smalldatetime columns. All string types can also be used with ntext, text, varchar, nchar and char columns. All binary types can also be used with binary and image columns.

See the time module for more information about the date and time structs.

Required Methods§

source

fn to_sql(&self) -> ColumnData<'_>

Convert to a value understood by the SQL Server. Conversion by-reference.

Implementations on Foreign Types§

source§

impl ToSql for &Option<&str>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<&[u8]>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<Cow<'_, str>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<Cow<'_, [u8]>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<bool>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<f32>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<f64>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<i16>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<i32>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<i64>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<u8>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<String>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<Vec<u8>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<BigDecimal>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<Numeric>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<Uuid>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<DateTime<FixedOffset>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<DateTime<Utc>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<NaiveDate>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<NaiveDateTime>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<NaiveTime>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &Option<XmlData>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &str

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for &[u8]

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Cow<'_, str>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Cow<'_, [u8]>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<&str>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<&[u8]>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<Cow<'_, str>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<Cow<'_, [u8]>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<bool>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<f32>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<f64>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<i16>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<i32>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<i64>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<u8>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<String>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<Vec<u8>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<BigDecimal>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<Numeric>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<Uuid>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<DateTime<FixedOffset>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<DateTime<Utc>>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<NaiveDate>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<NaiveDateTime>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<NaiveTime>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Option<XmlData>

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for bool

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for f32

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for f64

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for i16

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for i32

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for i64

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for u8

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for String

source§

fn to_sql(&self) -> ColumnData<'_>

source§

impl ToSql for Vec<u8>

source§

fn to_sql(&self) -> ColumnData<'_>

Implementors§