Skip to main content

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 read;
32mod sse;
33mod url;
34
35pub use error::NetError;
36pub use http::{HttpBodyMode, HttpHead, body_mode, parse_http_head};
37pub use line::LineDecoder;
38pub use ndjson::NdjsonDecoder;
39pub use read::{CapOutcome, HeadOutcome, read_capped_line, read_head_until_double_crlf};
40pub use sse::{SseDecoder, SseEvent};
41pub use url::{UrlParts, parse_url, parse_url_for_scheme};
42
43#[cfg(test)]
44mod tests;