pub struct LineAdapter<S> { /* private fields */ }Expand description
Adapter that drives LineParser over chunk events and dispatches every emitted line to
the inner LineSink (sync) or AsyncLineSink (async).
One struct, two trait impls: StreamVisitor when S: LineSink, AsyncStreamVisitor
when S: AsyncLineSink. Rust selects the right impl from the inner sink’s type at the
call site.
Implementations§
Source§impl<S> LineAdapter<S>
impl<S> LineAdapter<S>
Sourcepub fn new(options: LineParsingOptions, inner: S) -> Self
pub fn new(options: LineParsingOptions, inner: S) -> Self
Creates a new line adapter.
§Panics
Panics if options.max_line_length is zero. See
LineParsingOptions::max_line_length for the rationale; pass
crate::NumBytes::MAX for effectively-unbounded line parsing.
Trait Implementations§
Source§impl<S: AsyncLineSink> AsyncStreamVisitor for LineAdapter<S>
Async impl of the same LineAdapter struct.
impl<S: AsyncLineSink> AsyncStreamVisitor for LineAdapter<S>
Async impl of the same LineAdapter struct.
Each per-line iteration calls next_line synchronously, materializes the line as a fresh
String via Cow::into_owned, drops the parser borrow, then awaits the inner sink. The
allocation per line is the price of supporting async per-line callbacks on stable Rust —
holding a parser borrow across an .await is forbidden because the next iteration
re-borrows the parser.
Source§type Output = <S as AsyncLineSink>::Output
type Output = <S as AsyncLineSink>::Output
into_output after the visitor
has finished observing the stream. Returned via Consumer::wait
and Consumer::cancel.Source§async fn on_chunk(&mut self, chunk: Chunk) -> Next
async fn on_chunk(&mut self, chunk: Chunk) -> Next
Source§fn on_gap(&mut self)
fn on_gap(&mut self)
Source§fn into_output(self) -> Self::Output
fn into_output(self) -> Self::Output
Source§impl<S: LineSink> StreamVisitor for LineAdapter<S>
impl<S: LineSink> StreamVisitor for LineAdapter<S>
Source§type Output = <S as LineSink>::Output
type Output = <S as LineSink>::Output
into_output after the visitor has
finished observing the stream. Returned via Consumer::wait and
Consumer::cancel.