1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! # tds-protocol
//!
//! Pure implementation of the MS-TDS (Tabular Data Stream) protocol used by
//! Microsoft SQL Server.
//!
//! This crate provides `no_std` compatible packet structures, token parsing,
//! and serialization for TDS protocol versions 7.4 through 8.0.
//!
//! ## Features
//!
//! - `std` (default): Enable standard library support
//! - `alloc`: Enable allocation without full std (requires `alloc` crate)
//! - `encoding` (default): Enable collation-aware string encoding/decoding
//! via the [`Collation::encoding()`] method. Uses the `encoding_rs` crate.
//!
//! ## Collation-Aware VARCHAR Decoding
//!
//! When the `encoding` feature is enabled (default), this crate provides
//! comprehensive support for decoding VARCHAR data with locale-specific
//! character encodings. This is essential for databases using non-ASCII
//! collations (e.g., Japanese, Chinese, Korean, Cyrillic, Arabic, etc.).
//!
//! ### Supported Encodings
//!
//! | Code Page | Encoding | Languages |
//! |-----------|----------|-----------|
//! | 874 | Windows-874 (TIS-620) | Thai |
//! | 932 | Shift_JIS | Japanese |
//! | 936 | GBK/GB18030 | Simplified Chinese |
//! | 949 | EUC-KR | Korean |
//! | 950 | Big5 | Traditional Chinese |
//! | 1250 | Windows-1250 | Central/Eastern European |
//! | 1251 | Windows-1251 | Cyrillic |
//! | 1252 | Windows-1252 | Western European (default) |
//! | 1253 | Windows-1253 | Greek |
//! | 1254 | Windows-1254 | Turkish |
//! | 1255 | Windows-1255 | Hebrew |
//! | 1256 | Windows-1256 | Arabic |
//! | 1257 | Windows-1257 | Baltic |
//! | 1258 | Windows-1258 | Vietnamese |
//! | UTF-8 | UTF-8 | SQL Server 2019+ collations |
//!
//! ### Example
//!
//! ```rust,ignore
//! use tds_protocol::Collation;
//!
//! // Japanese collation (LCID 0x0411 = Japanese_CI_AS)
//! let collation = Collation { lcid: 0x0411, sort_id: 0 };
//! if let Some(encoding) = collation.encoding() {
//! // encoding is Shift_JIS
//! let (decoded, _, _) = encoding.decode(varchar_bytes);
//! }
//!
//! // Check if UTF-8 collation (SQL Server 2019+)
//! let utf8_collation = Collation { lcid: 0x0800_0409, sort_id: 0 };
//! assert!(utf8_collation.is_utf8()); // true, no transcoding needed
//! ```
//!
//! ## Design Philosophy
//!
//! This crate is intentionally IO-agnostic. It contains no networking logic and
//! makes no assumptions about the async runtime. Higher-level crates build upon
//! this foundation to provide async I/O capabilities.
//!
//! ## Example
//!
//! ```no_run
//! use tds_protocol::{PacketHeader, PacketType, PacketStatus};
//!
//! let header = PacketHeader {
//! packet_type: PacketType::SqlBatch,
//! status: PacketStatus::END_OF_MESSAGE,
//! length: 100,
//! spid: 0,
//! packet_id: 1,
//! window: 0,
//! };
//! ```
// This crate requires heap allocation (String, Vec). When std is disabled,
// the alloc feature must be enabled to provide these types.
compile_error!;
extern crate alloc;
// Internal prelude for no_std compatibility - provides String, Vec, Box, etc.
pub use ProtocolError;
pub use ;
pub use ;
pub use ;
pub use ;
pub use SqlBatch;
pub use ;
pub use ;
pub use ;
pub use ;
/// Internal wire-codec helpers shared across the workspace crates.
///
/// **Not public API.** These are low-level TDS encoders consumed cross-crate by
/// the rest of the driver; they are exempt from this crate's semver guarantees
/// and must not be used from outside the workspace. See #242.
// Always Encrypted metadata types
pub use ;