pub trait AsyncLineVisitor: Send + 'static {
type Output: Send + 'static;
// Required methods
fn on_line<'a>(
&'a mut self,
line: Cow<'a, str>,
) -> impl Future<Output = Next> + Send + 'a;
fn into_output(self) -> Self::Output;
// Provided methods
fn on_gap(&mut self) { ... }
fn on_eof(&mut self) -> impl Future<Output = ()> + Send + '_ { ... }
}Expand description
Async per-line action selected by the AsyncStreamVisitor impl of ParseLines.
on_line is async because async per-line work (writing to an async sink, awaiting a
channel) needs .await. on_gap stays synchronous because gap notification carries no
payload to await on, mirroring AsyncStreamVisitor::on_gap.
§Allocation note
The async path materializes every parsed line as an owned String before handing it to
on_line. The synchronous LineVisitor path can instead pass a Cow::Borrowed straight out
of the chunk on the fast path, so it avoids a per-line allocation when the line fits in the
current chunk. The allocation is the cost of holding the parser’s borrow across an .await,
which Rust does not allow because the next iteration re-borrows the parser. Prefer
LineVisitor (composed via ParseLines::inspect / ParseLines::collect) when
per-line work is non-blocking, and you want the zero-copy fast path; reach for
AsyncLineVisitor only when the per-line work genuinely needs to await.
Required Associated Types§
Required Methods§
Sourcefn on_line<'a>(
&'a mut self,
line: Cow<'a, str>,
) -> impl Future<Output = Next> + Send + 'a
fn on_line<'a>( &'a mut self, line: Cow<'a, str>, ) -> impl Future<Output = Next> + Send + 'a
Asynchronously observes a single parsed line. Return Next::Break to stop further
parsing.
Sourcefn into_output(self) -> Self::Output
fn into_output(self) -> Self::Output
Consumes the sink and returns its final output.
Provided Methods§
Sourcefn on_gap(&mut self)
fn on_gap(&mut self)
Synchronous gap hook; default no-op. See LineVisitor::on_gap.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.