Skip to main content

TypeId

Enum TypeId 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum TypeId {
Show 43 variants Null = 31, Int1 = 48, Bit = 50, Int2 = 52, Int4 = 56, Int8 = 127, DateTimeN = 111, Float4 = 59, Float8 = 62, Money = 60, Money4 = 122, DateTime = 61, DateTime4 = 58, Guid = 36, IntN = 38, Decimal = 55, Numeric = 63, BitN = 104, DecimalN = 106, NumericN = 108, FloatN = 109, MoneyN = 110, Char = 47, VarChar = 39, Binary = 45, VarBinary = 37, BigVarChar = 167, BigVarBinary = 165, BigChar = 175, BigBinary = 173, NChar = 239, NVarChar = 231, Text = 35, Image = 34, NText = 99, Date = 40, Time = 41, DateTime2 = 42, DateTimeOffset = 43, Variant = 98, Udt = 240, Xml = 241, Tvp = 243,
}
Expand description

TDS data type identifiers.

These correspond to the type bytes sent in column metadata and parameter definitions.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Null = 31

Null type.

§

Int1 = 48

8-bit signed integer.

§

Bit = 50

Bit (boolean).

§

Int2 = 52

16-bit signed integer.

§

Int4 = 56

32-bit signed integer.

§

Int8 = 127

64-bit signed integer.

§

DateTimeN = 111

4-byte datetime.

§

Float4 = 59

32-bit floating point.

§

Float8 = 62

64-bit floating point.

§

Money = 60

8-byte money.

§

Money4 = 122

4-byte money.

§

DateTime = 61

4-byte datetime.

§

DateTime4 = 58

4-byte small datetime.

§

Guid = 36

Variable-length GUID.

§

IntN = 38

Variable-length integer.

§

Decimal = 55

Variable-length decimal.

§

Numeric = 63

Variable-length numeric.

§

BitN = 104

Variable-length bit.

§

DecimalN = 106

Variable-length decimal (newer).

§

NumericN = 108

Variable-length numeric (newer).

§

FloatN = 109

Variable-length float.

§

MoneyN = 110

Variable-length money.

§

Char = 47

Fixed-length character.

§

VarChar = 39

Variable-length character.

§

Binary = 45

Fixed-length binary.

§

VarBinary = 37

Variable-length binary.

§

BigVarChar = 167

Large variable-length character.

§

BigVarBinary = 165

Large variable-length binary.

§

BigChar = 175

Large fixed-length character.

§

BigBinary = 173

Large fixed-length binary.

§

NChar = 239

Fixed-length Unicode character.

§

NVarChar = 231

Variable-length Unicode character.

§

Text = 35

Text (deprecated, use varchar(max)).

§

Image = 34

Image (deprecated, use varbinary(max)).

§

NText = 99

NText (deprecated, use nvarchar(max)).

§

Date = 40

Date (3 bytes).

§

Time = 41

Time with variable precision.

§

DateTime2 = 42

DateTime2 with variable precision.

§

DateTimeOffset = 43

DateTimeOffset with variable precision.

§

Variant = 98

SQL Variant.

§

Udt = 240

User-defined type.

§

Xml = 241

XML type.

§

Tvp = 243

Table-valued parameter.

Implementations§

Source§

impl TypeId

Source

pub fn from_u8(value: u8) -> Option<Self>

Create a type ID from a raw byte.

Source

pub const fn is_fixed_length(&self) -> bool

Check if this is a fixed-length type.

Source

pub const fn is_variable_length(&self) -> bool

Check if this is a variable-length type.

Source

pub const fn is_plp(&self) -> bool

Check if this type always uses PLP (Partially Length-Prefixed) encoding.

Note: NVarChar, BigVarChar, and BigVarBinary also use PLP encoding when declared as MAX types (max_length == 0xFFFF). This function only returns true for types that always use PLP.

Source

pub const fn can_be_max(&self) -> bool

Check if this type can use PLP encoding when declared as MAX.

Returns true for types that use PLP when max_length == 0xFFFF:

  • NVARCHAR(MAX)
  • VARCHAR(MAX)
  • VARBINARY(MAX)
Source

pub const fn is_unicode(&self) -> bool

Check if this is a Unicode type.

Source

pub const fn is_datetime(&self) -> bool

Check if this is a date/time type.

Source

pub const fn fixed_size(&self) -> Option<usize>

Get the fixed size of this type in bytes, if applicable.

Trait Implementations§

Source§

impl Clone for TypeId

Source§

fn clone(&self) -> TypeId

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TypeId

Source§

impl Debug for TypeId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for TypeId

Source§

impl Hash for TypeId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TypeId

Source§

fn eq(&self, other: &TypeId) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TypeId

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.