mssql_codec/
lib.rs

1//! # mssql-codec
2//!
3//! Async framing layer for TDS packet handling.
4//!
5//! This crate transforms raw byte streams into high-level TDS packets,
6//! handling packet reassembly across TCP segment boundaries and packet
7//! continuation for large messages.
8//!
9//! ## Features
10//!
11//! - Packet reassembly across TCP segments
12//! - Message reassembly from multiple packets
13//! - IO splitting for cancellation safety (ADR-005)
14//! - Integration with tokio-util's codec framework
15//!
16//! ## Architecture
17//!
18//! The codec layer sits between raw TCP streams and the higher-level client:
19//!
20//! ```text
21//! TCP Stream → TdsCodec (packet framing) → MessageAssembler → Client
22//! ```
23//!
24//! ### Cancellation Safety
25//!
26//! Per ADR-005, the connection splits the TCP stream into read and write halves.
27//! This allows sending Attention packets for query cancellation even while
28//! blocked reading a large result set.
29//!
30//! ```rust,ignore
31//! use mssql_codec::Connection;
32//!
33//! let conn = Connection::new(tcp_stream);
34//! let cancel = conn.cancel_handle();
35//!
36//! // Cancel from another task
37//! tokio::spawn(async move {
38//!     cancel.cancel().await?;
39//! });
40//! ```
41
42#![warn(missing_docs)]
43#![deny(unsafe_code)]
44
45pub mod connection;
46pub mod error;
47pub mod framed;
48pub mod message;
49pub mod packet_codec;
50
51pub use connection::{CancelHandle, Connection};
52pub use error::CodecError;
53pub use framed::{PacketReader, PacketStream, PacketWriter};
54pub use message::{Message, MessageAssembler};
55pub use packet_codec::{Packet, TdsCodec};