pub struct WriteLineSink<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
AsyncLineSink that maps each parsed line through mapper, writes the result via
writer, and routes failures through error_handler. Compose with
LineAdapter (its AsyncStreamVisitor impl
is selected automatically when the inner sink is an AsyncLineSink) to drive
collect_lines_into_write and friends, or to build your own custom write-lines consumer
outside the built-in factory methods.
Implementations§
Source§impl<W, H, F, B> WriteLineSink<W, H, F, B>
impl<W, H, F, B> WriteLineSink<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.
Trait Implementations§
Source§impl<W, H, F, B> AsyncLineSink for WriteLineSink<W, H, F, B>
impl<W, H, F, B> AsyncLineSink for WriteLineSink<W, H, F, B>
Source§type Output = Result<W, SinkWriteError>
type Output = Result<W, SinkWriteError>
Final value produced once the adapter is finished.
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
Asynchronously observes a single parsed line. Return
Next::Break to stop further
parsing.Source§fn into_output(self) -> Self::Output
fn into_output(self) -> Self::Output
Consumes the sink and returns its final output.
Source§fn on_gap(&mut self)
fn on_gap(&mut self)
Synchronous gap hook; default no-op. See
LineSink::on_gap.Auto Trait Implementations§
impl<W, H, F, B> Freeze for WriteLineSink<W, H, F, B>
impl<W, H, F, B> !RefUnwindSafe for WriteLineSink<W, H, F, B>
impl<W, H, F, B> Send for WriteLineSink<W, H, F, B>
impl<W, H, F, B> Sync for WriteLineSink<W, H, F, B>
impl<W, H, F, B> Unpin for WriteLineSink<W, H, F, B>
impl<W, H, F, B> UnsafeUnpin for WriteLineSink<W, H, F, B>
impl<W, H, F, B> !UnwindSafe for WriteLineSink<W, H, F, B>
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