tds_protocol/
lib.rs

1//! # tds-protocol
2//!
3//! Pure implementation of the MS-TDS (Tabular Data Stream) protocol used by
4//! Microsoft SQL Server.
5//!
6//! This crate provides `no_std` compatible packet structures, token parsing,
7//! and serialization for TDS protocol versions 7.4 through 8.0.
8//!
9//! ## Features
10//!
11//! - `std` (default): Enable standard library support
12//! - `alloc`: Enable allocation without full std (requires `alloc` crate)
13//!
14//! ## Design Philosophy
15//!
16//! This crate is intentionally IO-agnostic. It contains no networking logic and
17//! makes no assumptions about the async runtime. Higher-level crates build upon
18//! this foundation to provide async I/O capabilities.
19//!
20//! ## Example
21//!
22//! ```rust,ignore
23//! use tds_protocol::{PacketHeader, PacketType, PacketStatus};
24//!
25//! let header = PacketHeader {
26//!     packet_type: PacketType::SqlBatch,
27//!     status: PacketStatus::END_OF_MESSAGE,
28//!     length: 100,
29//!     spid: 0,
30//!     packet_id: 1,
31//!     window: 0,
32//! };
33//! ```
34
35#![cfg_attr(not(feature = "std"), no_std)]
36#![warn(missing_docs)]
37#![deny(unsafe_code)]
38
39#[cfg(feature = "alloc")]
40extern crate alloc;
41
42pub mod codec;
43pub mod error;
44pub mod login7;
45pub mod packet;
46pub mod prelogin;
47pub mod rpc;
48pub mod sql_batch;
49pub mod token;
50pub mod types;
51pub mod version;
52
53pub use error::ProtocolError;
54pub use login7::{
55    FeatureExtension, FeatureId, Login7, OptionFlags1, OptionFlags2, OptionFlags3, TypeFlags,
56};
57pub use packet::{
58    DEFAULT_PACKET_SIZE, MAX_PACKET_SIZE, PACKET_HEADER_SIZE, PacketHeader, PacketStatus,
59    PacketType,
60};
61pub use prelogin::{EncryptionLevel, PreLogin, PreLoginOption};
62pub use rpc::{ParamFlags, ProcId, RpcOptionFlags, RpcParam, RpcRequest, TypeInfo as RpcTypeInfo};
63pub use sql_batch::{SqlBatch, encode_sql_batch, encode_sql_batch_with_transaction};
64pub use token::{
65    ColMetaData, Collation, ColumnData, Done, DoneInProc, DoneProc, DoneStatus, EnvChange,
66    EnvChangeType, EnvChangeValue, FeatureExtAck, FedAuthInfo, LoginAck, NbcRow, Order, RawRow,
67    ReturnValue, ServerError, ServerInfo, SessionState, SspiToken, Token, TokenParser, TokenType,
68    TypeInfo,
69};
70pub use types::{ColumnFlags, TypeId, Updateable};
71pub use version::TdsVersion;