micro_http/protocol/
mod.rs

1//! Core HTTP protocol abstractions and implementations.
2//!
3//! This module provides the fundamental building blocks for HTTP protocol handling,
4//! including request/response processing, body streaming, and error handling.
5//! The design focuses on providing clean abstractions while maintaining high performance
6//! and memory efficiency.
7//!
8//! # Architecture
9//!
10//! The protocol module is organized into several key components:
11//!
12//! - **Message Handling** ([`message`]): Core message types and payload processing
13//!   - [`Message`]: Represents either headers or payload chunks
14//!   - [`PayloadItem`]: Handles individual payload chunks and EOF
15//!   - [`PayloadSize`]: Tracks payload size information
16//!
17//! - **Request Processing** ([`request`]): Request header handling
18//!   - [`RequestHeader`]: Wraps HTTP request headers with additional functionality
19//!
20//! - **Response Processing** ([`response`]): Response header handling
21//!   - [`ResponseHead`]: Type alias for response headers before body attachment
22//!
23//! - **Body Streaming** ([`body`]): Efficient body handling implementation
24//!   - [`ReqBody`]: Consumer side implementing `http_body::Body`
25//!   - [`ReqBodySender`]: Producer side for streaming body chunks
26//!
27//! - **Error Handling** ([`error`]): Comprehensive error types
28//!   - [`HttpError`]: Top-level error type
29//!   - [`ParseError`]: Request parsing errors
30//!   - [`SendError`]: Response sending errors
31//!
32//! # Design Goals
33//!
34//! 1. **Memory Efficiency**
35//!    - Stream request/response bodies instead of buffering
36//!    - Implement proper backpressure mechanisms
37//!
38//! 2. **Clean Abstractions**
39//!    - Provide intuitive interfaces for protocol handling
40//!    - Hide implementation complexity from consumers
41//!
42//! 3. **Protocol Correctness**
43//!    - Ensure proper HTTP protocol compliance
44//!    - Handle edge cases and error conditions gracefully
45//!
46//! 4. **Performance**
47//!    - Minimize allocations and copies
48//!    - Support concurrent processing where beneficial
49//!
50//! # Example Usage
51//!
52//! The protocol module is typically used through the connection layer rather than
53//! directly. However, understanding its components is crucial for implementing
54//! custom handlers or extending functionality.
55//!
56//! See individual module documentation for specific usage examples.
57
58mod message;
59pub use message::Message;
60pub use message::PayloadItem;
61pub use message::PayloadSize;
62
63mod request;
64pub use request::RequestHeader;
65
66mod response;
67pub use response::ResponseHead;
68
69mod error;
70pub use error::HttpError;
71pub use error::ParseError;
72pub use error::SendError;
73
74pub mod body;