Skip to main content

Crate sim_lib_net_core

Crate sim_lib_net_core 

Source
Expand description

Reusable, side-effect-free HTTP/streaming parsing primitives.

This is a leaf parsing crate: it contains URL parsing, HTTP response-head parsing, body-mode classification, line framing, and SSE/NDJSON record decoders. It deliberately contains no socket/TLS I/O and no application policy – callers own transport and event mapping.

The behavior here was extracted from sim-lib-agent-runner-http so that multiple runtime libs can share one tested implementation of the wire framing rather than each hand-rolling line accumulation and head parsing.

§Example

LineDecoder frames newline-delimited input, buffering a partial final line across pushes:

use sim_lib_net_core::LineDecoder;

let mut decoder = LineDecoder::new();
assert_eq!(decoder.push(b"a\nb"), vec![b"a".to_vec()]);
assert_eq!(decoder.push(b"c\n"), vec![b"bc".to_vec()]);

Structs§

HttpHead
A parsed HTTP response head: status line plus headers.
LineDecoder
Incremental newline framer.
NdjsonDecoder
Incremental newline-delimited JSON decoder.
SseDecoder
Incremental Server-Sent Events decoder.
SseEvent
A decoded Server-Sent Events record.
UrlParts
The structural components of an absolute URL.

Enums§

CapOutcome
The outcome of a single capped line read.
HeadOutcome
The outcome of reading an HTTP head up to the \r\n\r\n terminator.
HttpBodyMode
How the body following a response head should be read.
NetError
Errors produced by the net-core parsing primitives.

Functions§

body_mode
Classify how the body should be read, matching the client’s precedence.
parse_http_head
Parse a CRLF-delimited HTTP response head.
parse_url
Parse a scheme://host[:port][/path] URL.
parse_url_for_scheme
Parse a URL and require a specific scheme, applying default_path when the URL carries no path component.
read_capped_line
Read one line into buf, bounded to cap bytes.
read_head_until_double_crlf
Read an HTTP head byte-by-byte until the \r\n\r\n terminator, bounded to cap bytes.