TdsVersion

Struct TdsVersion 

Source
pub struct TdsVersion(/* private fields */);
Expand description

TDS protocol version.

Represents the version of the TDS protocol used for communication with SQL Server.

Implementations§

Source§

impl TdsVersion

Source

pub const V7_0: Self

TDS 7.0 (SQL Server 7.0)

Source

pub const V7_1: Self

TDS 7.1 (SQL Server 2000)

Source

pub const V7_1_REV1: Self

TDS 7.1 Revision 1 (SQL Server 2000 SP1)

Source

pub const V7_2: Self

TDS 7.2 (SQL Server 2005)

Source

pub const V7_3A: Self

TDS 7.3A (SQL Server 2008)

Source

pub const V7_3B: Self

TDS 7.3B (SQL Server 2008 R2)

Source

pub const V7_4: Self

TDS 7.4 (SQL Server 2012+)

Source

pub const V8_0: Self

TDS 8.0 (SQL Server 2022+ strict encryption mode)

Source

pub const fn new(version: u32) -> Self

Create a new TDS version from raw bytes.

Source

pub const fn raw(self) -> u32

Get the raw version value.

Source

pub const fn is_tds_8(self) -> bool

Check if this version supports TDS 8.0 strict encryption.

Source

pub const fn requires_prelogin_encryption_negotiation(self) -> bool

Check if this version requires pre-login encryption negotiation.

TDS 7.x versions negotiate encryption during pre-login. TDS 8.0 requires TLS before any TDS traffic.

Source

pub const fn is_tds_7_3(self) -> bool

Check if this version is TDS 7.3 (SQL Server 2008/2008 R2).

Returns true for both TDS 7.3A (SQL Server 2008) and TDS 7.3B (SQL Server 2008 R2).

Source

pub const fn is_tds_7_4(self) -> bool

Check if this version is TDS 7.4 (SQL Server 2012+).

Source

pub const fn supports_date_time_types(self) -> bool

Check if this version supports DATE, TIME, DATETIME2, and DATETIMEOFFSET types.

These types were introduced in TDS 7.3 (SQL Server 2008). Returns true for TDS 7.3+, TDS 7.4, and TDS 8.0.

Source

pub const fn supports_session_recovery(self) -> bool

Check if this version supports session recovery (connection resiliency).

Session recovery was introduced in TDS 7.4 (SQL Server 2012).

Source

pub const fn supports_column_encryption(self) -> bool

Check if this version supports column encryption (Always Encrypted).

Column encryption was introduced in SQL Server 2016 (still TDS 7.4). This checks protocol capability, not SQL Server version.

Source

pub const fn supports_utf8(self) -> bool

Check if this version supports UTF-8 (introduced in SQL Server 2019).

Source

pub const fn is_legacy(self) -> bool

Check if this is a legacy version (TDS 7.2 or earlier).

Legacy versions (SQL Server 2005 and earlier) have different behaviors for some protocol aspects. This driver’s minimum supported version is TDS 7.3 for full functionality.

Source

pub const fn min(self, other: Self) -> Self

Get the minimum version between this version and another.

Useful for version negotiation where the client and server agree on the lowest common version.

Note: TDS 8.0 uses a different encoding (0x08000000) which is numerically lower than TDS 7.x versions, but semantically higher. This method handles that special case correctly.

Source

pub const fn sql_server_version_name(&self) -> &'static str

Get the SQL Server version name for this TDS version.

Returns a human-readable string describing the SQL Server version that corresponds to this TDS protocol version.

Source

pub fn parse(s: &str) -> Option<Self>

Parse a TDS version from a string representation.

Accepts formats like:

  • “7.3”, “7.3A”, “7.3a”, “7.3B”, “7.3b” for TDS 7.3
  • “7.4” for TDS 7.4
  • “8.0”, “8” for TDS 8.0

Returns None if the string cannot be parsed.

Source

pub const fn major(self) -> u8

Get the major version number.

Returns 7 for TDS 7.x versions, 8 for TDS 8.0.

Note: This extracts the major version from the wire format. All TDS 7.x versions return 7, and TDS 8.0 returns 8.

Source

pub const fn minor(self) -> u8

Get the minor version number.

Returns the TDS sub-version: 0, 1, 2, 3, or 4 for TDS 7.x, and 0 for TDS 8.0.

Note: The wire format uses different encoding for different versions. This method extracts the logical minor version (e.g., 3 for TDS 7.3).

Source

pub const fn revision_suffix(self) -> Option<char>

Get the revision suffix for TDS 7.3 versions.

Returns Some(‘A’) for TDS 7.3A (SQL Server 2008), Some(‘B’) for TDS 7.3B (SQL Server 2008 R2), and None for all other versions.

Trait Implementations§

Source§

impl Clone for TdsVersion

Source§

fn clone(&self) -> TdsVersion

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TdsVersion

Source§

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

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

impl Default for TdsVersion

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for TdsVersion

Source§

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

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

impl From<TdsVersion> for u32

Source§

fn from(version: TdsVersion) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for TdsVersion

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl Hash for TdsVersion

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 Ord for TdsVersion

Source§

fn cmp(&self, other: &TdsVersion) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for TdsVersion

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialOrd for TdsVersion

Source§

fn partial_cmp(&self, other: &TdsVersion) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for TdsVersion

Source§

impl Eq for TdsVersion

Source§

impl StructuralPartialEq for TdsVersion

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.