Skip to main content

LineSink

Trait LineSink 

Source
pub trait LineSink: Send + 'static {
    type Output: Send + 'static;

    // Required methods
    fn on_line(&mut self, line: Cow<'_, str>) -> Next;
    fn into_output(self) -> Self::Output;

    // Provided methods
    fn on_gap(&mut self) { ... }
    fn on_eof(&mut self) { ... }
}
Expand description

Per-line action selected by the StreamVisitor impl of LineAdapter.

Implementors only describe what should happen for each parsed line; chunk parsing, gap handling, and EOF flushing are carried by the adapter.

Required Associated Types§

Source

type Output: Send + 'static

Final value produced once the adapter is finished. Returned via Consumer::wait.

Required Methods§

Source

fn on_line(&mut self, line: Cow<'_, str>) -> Next

Invoked for every parsed line. Return Next::Break to stop further parsing.

Source

fn into_output(self) -> Self::Output

Consumes the sink and returns its final output.

Provided Methods§

Source

fn on_gap(&mut self)

Invoked after the adapter resets the parser following a stream gap. The default does nothing; override when the inner sink keeps line-spanning state that the gap invalidates.

Source

fn on_eof(&mut self)

Invoked once the adapter finishes flushing any trailing line at EOF. The default does nothing; override for sinks that want a finalization hook beyond the last on_line call.

Implementors§

Source§

impl<F> LineSink for InspectLineSink<F>
where F: FnMut(Cow<'_, str>) -> Next + Send + 'static,

Source§

impl<P> LineSink for WaitForLineSink<P>
where P: Fn(Cow<'_, str>) -> bool + Send + Sync + 'static,

Source§

impl<T, F> LineSink for CollectLineSink<T, F>
where T: Sink, F: FnMut(Cow<'_, str>, &mut T) -> Next + Send + 'static,