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
versionto the requested TDS version - Server → Client:
server_versioncontains 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: TdsVersionTDS 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: u16Sub-build version (legacy, now part of server_version).
encryption: EncryptionLevelEncryption level.
instance: Option<String>Instance name (for named instances).
thread_id: Option<u32>Thread ID.
mars: boolMARS enabled.
trace_id: Option<TraceId>Trace ID (Activity ID and Sequence).
fed_auth_required: boolFederated authentication required.
nonce: Option<[u8; 32]>Nonce for encryption.
Implementations§
Source§impl PreLogin
impl PreLogin
Sourcepub fn with_version(self, version: TdsVersion) -> Self
pub fn with_version(self, version: TdsVersion) -> Self
Set the TDS version.
Sourcepub fn with_encryption(self, level: EncryptionLevel) -> Self
pub fn with_encryption(self, level: EncryptionLevel) -> Self
Set the encryption level.
Sourcepub fn with_instance(self, instance: impl Into<String>) -> Self
pub fn with_instance(self, instance: impl Into<String>) -> Self
Set the instance name.
Sourcepub fn decode(src: impl Buf) -> Result<Self, ProtocolError>
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.