Skip to main content

LineFramer

Struct LineFramer 

Source
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

Source

pub const fn new(maximum: u64) -> Self

Create an empty framer with the caller’s per-frame byte allowance.

Source

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.

Source

pub fn finish(self) -> Result<(), FrameReadError>

Finish cleanly at a frame boundary, or return the owned unterminated tail.

Callers may explicitly accept that tail when their protocol permits it.

§Errors

Returns an unterminated frame, or invalid input after an earlier refusal.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.