pub struct LineFramer { /* private fields */ }Expand description
Incremental newline framing for process-output callbacks.
The byte allowance includes the newline. Completed frames borrow reusable scratch until the callback returns. JSON, EOF acceptance, process lifetime and deadlines remain caller policy. After any failure, stop using the framer; no later input is admitted or implicitly drained.
Implementations§
Source§impl LineFramer
impl LineFramer
Sourcepub const fn new(maximum: u64) -> Self
pub const fn new(maximum: u64) -> Self
Create an empty framer with the caller’s per-frame byte allowance.
Sourcepub fn feed(
&mut self,
chunk: &[u8],
emit: impl FnMut(&[u8]) -> Result<()>,
) -> Result<(), FrameReadError>
pub fn feed( &mut self, chunk: &[u8], emit: impl FnMut(&[u8]) -> Result<()>, ) -> Result<(), FrameReadError>
Deliver each complete newline-terminated frame in order, retaining a tail.
Oversized frames retain at most the allowance plus one refused byte. On failure, the rest of this supplied chunk is abandoned; the caller must stop the stream or choose its own recovery. Allocator capacity is not a byte allowance, and already emitted frames are not rolled back.
§Errors
Returns overflow, the original allocation/sink failure, or an invalid-input I/O error when called again after refusal. Display never includes bytes.