micro_http/codec/mod.rs
1//! HTTP codec module for encoding and decoding HTTP messages
2//!
3//! This module provides functionality for streaming HTTP message processing,
4//! including request decoding and response encoding. It uses a state machine
5//! pattern to handle both headers and payload data efficiently.
6//!
7//! # Architecture
8//!
9//! The codec module is organized into several components:
10//!
11//! - Request handling:
12//! - [`RequestDecoder`]: Decodes incoming HTTP requests
13//! - Header parsing via [`header`] module
14//! - Payload decoding via [`body`] module
15//!
16//! - Response handling:
17//! - [`ResponseEncoder`]: Encodes outgoing HTTP responses
18//! - Header encoding via [`header`] module
19//! - Payload encoding via [`body`] module
20//!
21//! # Example
22//!
23//! ```no_run
24//! use micro_http::codec::{RequestDecoder, ResponseEncoder};
25//! use tokio_util::codec::{Decoder, Encoder};
26//! use bytes::BytesMut;
27//!
28//! // Decode incoming request
29//! let mut decoder = RequestDecoder::new();
30//! let mut request_buffer = BytesMut::new();
31//! let request = decoder.decode(&mut request_buffer);
32//!
33//! // Encode outgoing response
34//! let mut encoder = ResponseEncoder::new();
35//! let mut response_buffer = BytesMut::new();
36//! // ... encode response ...
37//! ```
38//!
39//! # Features
40//!
41//! - Streaming processing of HTTP messages
42//! - Support for chunked transfer encoding
43//! - Content-Length based payload handling
44//! - Efficient header parsing and encoding
45//! - State machine based processing
46
47mod body;
48mod header;
49mod request_decoder;
50mod response_encoder;
51
52pub use request_decoder::RequestDecoder;
53pub use response_encoder::ResponseEncoder;