sim_lib_net_core/lib.rs
1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3//! Reusable, side-effect-free HTTP/streaming parsing primitives.
4//!
5//! This is a leaf parsing crate: it contains URL parsing, HTTP response-head
6//! parsing, body-mode classification, line framing, and SSE/NDJSON record
7//! decoders. It deliberately contains **no** socket/TLS I/O and **no**
8//! application policy -- callers own transport and event mapping.
9//!
10//! The behavior here was extracted from `sim-lib-agent-runner-http` so that
11//! multiple runtime libs can share one tested implementation of the wire
12//! framing rather than each hand-rolling line accumulation and head parsing.
13//!
14//! # Example
15//!
16//! `LineDecoder` frames newline-delimited input, buffering a partial final line
17//! across pushes:
18//!
19//! ```
20//! use sim_lib_net_core::LineDecoder;
21//!
22//! let mut decoder = LineDecoder::new();
23//! assert_eq!(decoder.push(b"a\nb"), vec![b"a".to_vec()]);
24//! assert_eq!(decoder.push(b"c\n"), vec![b"bc".to_vec()]);
25//! ```
26
27mod error;
28mod http;
29mod line;
30mod ndjson;
31mod sse;
32mod url;
33
34pub use error::NetError;
35pub use http::{HttpBodyMode, HttpHead, body_mode, parse_http_head};
36pub use line::LineDecoder;
37pub use ndjson::NdjsonDecoder;
38pub use sse::{SseDecoder, SseEvent};
39pub use url::{UrlParts, parse_url};
40
41#[cfg(test)]
42mod tests;