PreLogin

Struct PreLogin 

Source
pub struct PreLogin {
    pub version: TdsVersion,
    pub server_version: Option<SqlServerVersion>,
    pub sub_build: u16,
    pub encryption: EncryptionLevel,
    pub instance: Option<String>,
    pub thread_id: Option<u32>,
    pub mars: bool,
    pub trace_id: Option<TraceId>,
    pub fed_auth_required: bool,
    pub nonce: Option<[u8; 32]>,
}
Expand description

Pre-login message builder and parser.

This struct is used for both client requests and server responses:

  • Client → Server: Set version to the requested TDS version
  • Server → Client: server_version contains the SQL Server product version

Note: The VERSION field has different semantics in each direction:

  • Client sends: TDS protocol version (e.g., 7.4)
  • Server sends: SQL Server product version (e.g., 13.0.6300 for SQL Server 2016)

Fields§

§version: TdsVersion

TDS version (client request).

This is the TDS protocol version the client requests. When sending a PreLogin, set this to the desired TDS version.

§server_version: Option<SqlServerVersion>

SQL Server product version (server response).

When decoding a PreLogin response from the server, this contains the SQL Server product version (e.g., 13.0.6300 for SQL Server 2016). This is NOT the TDS version - the actual TDS version is negotiated in the LOGINACK token after login.

§sub_build: u16
👎Deprecated since 0.5.2: Use server_version.sub_build instead

Sub-build version (legacy, now part of server_version).

§encryption: EncryptionLevel

Encryption level.

§instance: Option<String>

Instance name (for named instances).

§thread_id: Option<u32>

Thread ID.

§mars: bool

MARS enabled.

§trace_id: Option<TraceId>

Trace ID (Activity ID and Sequence).

§fed_auth_required: bool

Federated authentication required.

§nonce: Option<[u8; 32]>

Nonce for encryption.

Implementations§

Source§

impl PreLogin

Source

pub fn new() -> Self

Create a new pre-login message with default values.

Source

pub fn with_version(self, version: TdsVersion) -> Self

Set the TDS version.

Source

pub fn with_encryption(self, level: EncryptionLevel) -> Self

Set the encryption level.

Source

pub fn with_mars(self, enabled: bool) -> Self

Enable MARS.

Source

pub fn with_instance(self, instance: impl Into<String>) -> Self

Set the instance name.

Source

pub fn encode(&self) -> Bytes

Encode the pre-login message to bytes.

Source

pub fn decode(src: impl Buf) -> Result<Self, ProtocolError>

Decode a pre-login response from the server.

Per MS-TDS spec 2.2.6.4, PreLogin message structure:

  • Option headers: each 5 bytes (type:1 + offset:2 + length:2)
  • Terminator: 1 byte (0xFF)
  • Option data: variable length, positioned at offsets specified in headers

Offsets in headers are absolute from the start of the PreLogin packet payload.

Trait Implementations§

Source§

impl Clone for PreLogin

Source§

fn clone(&self) -> PreLogin

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 PreLogin

Source§

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

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

impl Default for PreLogin

Source§

fn default() -> PreLogin

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

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.