Skip to main content

LineAdapter

Struct LineAdapter 

Source
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>

Source

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.

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

The value produced by 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

Asynchronously observes a single chunk. Read more
Source§

fn on_gap(&mut self)

Invoked when the stream backend reports that one or more chunks were dropped between the last delivered chunk and the next one. Read more
Source§

async fn on_eof(&mut self)

Asynchronously observes end-of-stream. Read more
Source§

fn into_output(self) -> Self::Output

Consumes the visitor and returns its final output. Read more
Source§

impl<S: LineSink> StreamVisitor for LineAdapter<S>

Source§

type Output = <S as LineSink>::Output

The value produced by into_output after the visitor has finished observing the stream. Returned via Consumer::wait and Consumer::cancel.
Source§

fn on_chunk(&mut self, chunk: Chunk) -> Next

Invoked for every chunk observed on the stream. Read more
Source§

fn on_gap(&mut self)

Invoked when the stream backend reports that one or more chunks were dropped between the last delivered chunk and the next one. Read more
Source§

fn on_eof(&mut self)

Invoked exactly once when the stream ends (EOF or write side dropped). Read more
Source§

fn into_output(self) -> Self::Output

Consumes the visitor and returns its final output. Read more

Auto Trait Implementations§

§

impl<S> Freeze for LineAdapter<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for LineAdapter<S>
where S: RefUnwindSafe,

§

impl<S> Send for LineAdapter<S>
where S: Send,

§

impl<S> Sync for LineAdapter<S>
where S: Sync,

§

impl<S> Unpin for LineAdapter<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for LineAdapter<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for LineAdapter<S>
where S: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Sink for T
where T: Send + 'static,