Skip to main content

Module encode

Module encode 

Source
Expand description

TDS binary encoding for SQL values.

This module provides encoding of Rust values into TDS wire format for transmission to SQL Server.

Traits§

TdsEncode
Trait for encoding values to TDS binary format.

Functions§

datetime_to_legacy_days_ticks
Convert a NaiveDateTime to the DATETIME wire representation.
datetime_to_smalldatetime_days_minutes
Convert a NaiveDateTime to the SMALLDATETIME wire representation.
decimal_to_money_cents_i64
Convert a decimal to the scaled i64 used on the MONEY wire.
decimal_to_smallmoney_cents_i32
Convert a decimal to the scaled i32 used on the SMALLMONEY wire.
encode_date
Encode a DATE value.
encode_datetime2
Encode a DATETIME2 value.
encode_datetime_legacy
Encode a DATETIME value (8 bytes): days since 1900 (i32 LE) + time units since midnight (u32 LE) where each unit is 1/300 of a second.
encode_datetimeoffset
Encode a DATETIMEOFFSET value.
encode_decimal
Encode a decimal value.
encode_money
Encode a decimal as MONEY (8 bytes): the signed 64-bit scaled integer is written as the high 32 bits LE followed by the low 32 bits LE, per MS-TDS §2.2.5.5.1.2.
encode_smalldatetime
Encode a SMALLDATETIME value (4 bytes): days since 1900 (u16 LE) + minutes since midnight (u16 LE). Seconds are rounded to the nearest minute (30s rounds up per SQL Server semantics).
encode_smallmoney
Encode a decimal as SMALLMONEY (4 bytes): the signed 32-bit scaled integer is written little-endian.
encode_time
Encode a TIME value.
encode_utf16_string
Encode a string as UTF-16LE with length prefix.
encode_utf16_string_no_len
Encode a string as UTF-16LE without length prefix (for fixed-length fields).
encode_uuid
Encode a UUID in SQL Server’s mixed-endian format.