pub struct NdjsonDecoder { /* private fields */ }Expand description
Incremental newline-delimited JSON decoder.
Each complete line is returned verbatim as one record string (parsing is the
caller’s job). A partial final line is buffered until a later push completes
it or flush is called. Blank lines are skipped.
The default constructor uses DEFAULT_MAX_LINE_BYTES to guard against an
unbounded buffered line on an adversarial stream; exceeding it fails closed
with NetError::LineTooLong. unbounded is
the explicit opt-out for trusted in-memory inputs.
Implementations§
Source§impl NdjsonDecoder
impl NdjsonDecoder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a decoder using DEFAULT_MAX_LINE_BYTES.
Sourcepub fn unbounded() -> Self
pub fn unbounded() -> Self
Create a decoder with no per-line size limit.
Use this only for trusted, already-bounded inputs.
Sourcepub fn with_max_line_bytes(max_line_bytes: usize) -> Self
pub fn with_max_line_bytes(max_line_bytes: usize) -> Self
Create a decoder that rejects any line (or buffered partial) exceeding
max_line_bytes.
Sourcepub fn push(&mut self, bytes: &[u8]) -> Result<Vec<String>, NetError>
pub fn push(&mut self, bytes: &[u8]) -> Result<Vec<String>, NetError>
Append bytes and return completed JSON record strings, skipping blank lines. Fails closed if any completed line or the buffered remainder exceeds the configured limit.