[][src]Trait tiberius::ToSql

pub trait ToSql: Send + Sync {
    fn to_sql(&self) -> ColumnData;
}

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
i8tinyint
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
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

fn to_sql(&self) -> ColumnData

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

Loading content...

Implementations on Foreign Types

impl ToSql for bool[src]

impl ToSql for Option<bool>[src]

impl<'_> ToSql for &'_ Option<bool>[src]

impl ToSql for i8[src]

impl ToSql for Option<i8>[src]

impl<'_> ToSql for &'_ Option<i8>[src]

impl ToSql for i16[src]

impl ToSql for Option<i16>[src]

impl<'_> ToSql for &'_ Option<i16>[src]

impl ToSql for i32[src]

impl ToSql for Option<i32>[src]

impl<'_> ToSql for &'_ Option<i32>[src]

impl ToSql for i64[src]

impl ToSql for Option<i64>[src]

impl<'_> ToSql for &'_ Option<i64>[src]

impl ToSql for f32[src]

impl ToSql for Option<f32>[src]

impl<'_> ToSql for &'_ Option<f32>[src]

impl ToSql for f64[src]

impl ToSql for Option<f64>[src]

impl<'_> ToSql for &'_ Option<f64>[src]

impl<'_> ToSql for &'_ str[src]

impl<'_> ToSql for Option<&'_ str>[src]

impl<'_, '_> ToSql for &'_ Option<&'_ str>[src]

impl ToSql for String[src]

impl ToSql for Option<String>[src]

impl<'_> ToSql for &'_ Option<String>[src]

impl<'_> ToSql for Cow<'_, str>[src]

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

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

impl<'_> ToSql for &'_ [u8][src]

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

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

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

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

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

impl ToSql for Vec<u8>[src]

impl ToSql for Option<Vec<u8>>[src]

impl<'_> ToSql for &'_ Option<Vec<u8>>[src]

impl ToSql for Option<Numeric>[src]

impl<'_> ToSql for &'_ Option<Numeric>[src]

impl ToSql for Option<XmlData>[src]

impl<'_> ToSql for &'_ Option<XmlData>[src]

impl ToSql for Option<Uuid>[src]

impl<'_> ToSql for &'_ Option<Uuid>[src]

impl ToSql for Option<NaiveDate>[src]

impl<'_> ToSql for &'_ Option<NaiveDate>[src]

impl ToSql for Option<NaiveTime>[src]

impl<'_> ToSql for &'_ Option<NaiveTime>[src]

impl ToSql for Option<NaiveDateTime>[src]

impl<'_> ToSql for &'_ Option<NaiveDateTime>[src]

impl ToSql for Option<DateTime<Utc>>[src]

impl<'_> ToSql for &'_ Option<DateTime<Utc>>[src]

impl ToSql for Option<DateTime<FixedOffset>>[src]

impl<'_> ToSql for &'_ Option<DateTime<FixedOffset>>[src]

Loading content...

Implementors

impl ToSql for Numeric[src]

impl ToSql for Uuid[src]

impl ToSql for DateTime<FixedOffset>[src]

impl ToSql for DateTime<Utc>[src]

impl ToSql for NaiveDate[src]

impl ToSql for NaiveDateTime[src]

impl ToSql for NaiveTime[src]

impl ToSql for XmlData[src]

Loading content...