Skip to main content

marque_engine/
pipeline.rs

1//! Async stream pipeline types.
2//!
3//! The full pipeline:
4//!   Source → TextStream → SpanStream → AttributeStream → DiagnosticStream → Sink
5//!
6//! Each stage is a `Stream`. Middleware inserts between stages.
7//! This module defines the stage types; full async streaming implementation is TODO.
8
9use marque_ism::MarkingCandidate;
10use marque_rules::Diagnostic;
11
12/// A chunk of source text with its byte offset in the original document.
13#[derive(Debug)]
14pub struct TextChunk {
15    pub offset: usize,
16    pub data: Vec<u8>,
17}
18
19/// A stream source — anything that produces `TextChunk`s.
20/// Implemented by: string buffer (WASM/server), file reader (CLI/batch), HTTP body.
21pub trait Source: Send {
22    // TODO: implement as futures::Stream<Item = Result<TextChunk, SourceError>>
23}
24
25/// A stream sink — anything that consumes pipeline output.
26pub trait Sink: Send {
27    fn accept_diagnostic(&mut self, diag: Diagnostic);
28    fn accept_candidate(&mut self, candidate: MarkingCandidate);
29}