pub struct WriteLines<W, H, F, B>where
W: Sink + AsyncWriteExt + Unpin,
H: SinkWriteErrorHandler,
B: AsRef<[u8]> + Send + 'static,
F: Fn(Cow<'_, str>) -> B + Send + Sync + 'static,{ /* private fields */ }Expand description
AsyncLineVisitor that maps each parsed line through mapper, writes the result via
writer, and routes failures through error_handler. Compose with
ParseLines (its
AsyncStreamVisitor impl is selected automatically when the inner sink is an
AsyncLineVisitor) and pass the resulting visitor to
Consumable::consume_async.
The common identity-mapper shape has a dedicated constructor: WriteLines::passthrough.
For mappers that change the line bytes, use WriteLines::new with a typed mapper
closure.
Implementations§
Source§impl<W, H, F, B> WriteLines<W, H, F, B>
impl<W, H, F, B> WriteLines<W, H, F, B>
Sourcepub fn new(
stream_name: &'static str,
writer: W,
error_handler: H,
mapper: F,
mode: LineWriteMode,
) -> Self
pub fn new( stream_name: &'static str, writer: W, error_handler: H, mapper: F, mode: LineWriteMode, ) -> Self
Creates a new sink that maps each parsed line through mapper, writes the result to
writer with the requested mode, and routes failures through error_handler.
stream_name labels the stream in any SinkWriteError this sink emits.
Source§impl<W, H> WriteLines<W, H, fn(Cow<'_, str>) -> String, String>
impl<W, H> WriteLines<W, H, fn(Cow<'_, str>) -> String, String>
Sourcepub fn passthrough(
stream_name: &'static str,
writer: W,
options: WriteCollectionOptions<H>,
mode: LineWriteMode,
) -> Self
pub fn passthrough( stream_name: &'static str, writer: W, options: WriteCollectionOptions<H>, mode: LineWriteMode, ) -> Self
Identity-mapper constructor. Each parsed line is written to writer (with mode)
without transformation. stream_name labels any SinkWriteError this sink emits.
Trait Implementations§
Source§impl<W, H, F, B> AsyncLineVisitor for WriteLines<W, H, F, B>
impl<W, H, F, B> AsyncLineVisitor for WriteLines<W, H, F, B>
Source§type Output = Result<W, SinkWriteError>
type Output = Result<W, SinkWriteError>
Source§async fn on_line<'a>(&'a mut self, line: Cow<'a, str>) -> Next
async fn on_line<'a>(&'a mut self, line: Cow<'a, str>) -> Next
Next::Break to stop further
parsing.Source§fn into_output(self) -> Self::Output
fn into_output(self) -> Self::Output
Source§fn on_gap(&mut self)
fn on_gap(&mut self)
LineVisitor::on_gap.