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
//! # SansIO Codec - Protocol Codecs for SansIO
//!
//! `sansio-codec` provides reusable codec implementations for the sansio ecosystem,
//! including frame decoders, string codecs, and transport abstractions.
//!
//! ## Features
//!
//! - **Frame Decoders**: Line-based frame decoders for parsing delimited streams
//! - **String Codecs**: UTF-8 string encoding/decoding
//! - **Transport Abstractions**: Tagged message types with transport metadata
//! - **Sans-IO Design**: Pure protocol logic without I/O dependencies
//!
//! ## Quick Start
//!
//! ```toml
//! [dependencies]
//! sansio-codec = "0.0.8"
//! ```
//!
//! ## Building a Pipeline with Codecs
//!
//! ```rust,no_run
//! use sansio::Pipeline;
//! use sansio_codec::{
//! LineBasedFrameDecoder, TaggedByteToMessageCodec, TaggedStringCodec, TerminatorType,
//! };
//! use sansio_transport::{TaggedBytesMut, TaggedString};
//!
//! let mut pipeline = Pipeline::<TaggedBytesMut, TaggedString>::new();
//!
//! // Add line-based frame decoder
//! let frame_decoder = TaggedByteToMessageCodec::new(Box::new(
//! LineBasedFrameDecoder::new(8192, true, TerminatorType::BOTH)
//! ));
//! pipeline.add_back(frame_decoder);
//!
//! // Add string codec
//! pipeline.add_back(TaggedStringCodec::new());
//!
//! // Add your business logic handler
//! // pipeline.add_back(your_handler);
//!
//! pipeline.finalize();
//! ```
//!
//! For shared pipelines (e.g., UDP servers), use `RcPipeline`:
//!
//! ```rust,no_run
//! use sansio::RcPipeline;
//! use sansio_codec::{TaggedByteToMessageCodec, TaggedStringCodec};
//! use sansio_transport::{TaggedBytesMut, TaggedString};
//! use std::rc::Rc;
//!
//! let mut pipeline = RcPipeline::<TaggedBytesMut, TaggedString>::new();
//! // ... add handlers ...
//! pipeline.finalize();
//! let pipeline = Rc::new(pipeline); // Now shareable
//! ```
//!
//! ## Modules
//!
//! - [`byte_to_message_decoder`]: Frame decoders for parsing byte streams
//! - [`string_codec`]: UTF-8 string encoding/decoding handlers
//!
//! ## Transport Context
//!
//! The transport module provides tagged message types that carry metadata:
//!
//! ```rust
//! use sansio_transport::{TransportContext, TaggedBytesMut, TransportProtocol};
//! use std::time::Instant;
//! use bytes::BytesMut;
//!
//! let msg = TaggedBytesMut {
//! now: Instant::now(),
//! transport: TransportContext {
//! local_addr: "127.0.0.1:8080".parse().unwrap(),
//! peer_addr: "127.0.0.1:1234".parse().unwrap(),
//! transport_protocol: TransportProtocol::TCP,
//! ecn: None,
//! },
//! message: BytesMut::from("Hello"),
//! };
//! ```
/// Byte-to-message frame decoders for parsing delimited streams
/// UTF-8 string encoding/decoding handlers
// Re-export commonly used types
pub use ;
pub use TaggedStringCodec;