pub struct LineBuffer { /* private fields */ }Expand description
Accumulates bytes from a chunk-shaped stream and yields complete LF-delimited lines. CRLF endings are normalized to LF before yield.
The buffer holds bytes until the next LF arrives; the trailing fragment after the last LF is retained for the next push.
UTF-8 decoding is best-effort: if a chunk lands mid-codepoint we
hold the partial codepoint until the next chunk completes it. Pure
invalid UTF-8 surfaces as a replacement character per
String::from_utf8_lossy.
Implementations§
Source§impl LineBuffer
impl LineBuffer
pub fn new() -> Self
Sourcepub fn push(&mut self, chunk: &[u8]) -> Vec<String>
pub fn push(&mut self, chunk: &[u8]) -> Vec<String>
Push chunk into the buffer. Returns all complete LF-delimited
lines (CR stripped) that became available; the tail is retained
for the next push.
Trait Implementations§
Source§impl Debug for LineBuffer
impl Debug for LineBuffer
Source§impl Default for LineBuffer
impl Default for LineBuffer
Source§fn default() -> LineBuffer
fn default() -> LineBuffer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LineBuffer
impl RefUnwindSafe for LineBuffer
impl Send for LineBuffer
impl Sync for LineBuffer
impl Unpin for LineBuffer
impl UnsafeUnpin for LineBuffer
impl UnwindSafe for LineBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.