pub struct Scanner { /* private fields */ }Expand description
Stateless sentinel matcher.
Scanner::new(until_tokens) builds one; feed
tests a single reconstructed line; scan folds an
iterator of lines into a single priority-respecting outcome.
The type holds no interior mutable state, so a single Scanner is
safe to share across threads for the rare case where multiple
streams feed the same loop controller.
Implementations§
Source§impl Scanner
impl Scanner
Sourcepub fn new<S: AsRef<str>>(tokens: &[S]) -> Self
pub fn new<S: AsRef<str>>(tokens: &[S]) -> Self
Build a scanner that always watches for BLOCKED plus every
non-empty, unique until token in tokens.
Any token that trims to empty is dropped; passing
BLOCKED explicitly is a no-op (it is always reserved).
Sourcepub fn feed(&self, line: &str) -> Option<Hit>
pub fn feed(&self, line: &str) -> Option<Hit>
Test a single reconstructed line for an exact-token match.
Returns Some(Hit { kind: Blocked, .. }) when the trimmed line
equals BLOCKED; returns Some(Hit { kind: Until, .. })
when it equals any registered until token; otherwise None.
BLOCKED is checked first so a caller that registered it by
mistake via tokens still gets the correct Kind.
Sourcepub fn scan<L, I>(&self, lines: I) -> Option<Hit>
pub fn scan<L, I>(&self, lines: I) -> Option<Hit>
Fold an iterator of lines into a priority-respecting outcome.
Returns the first Hit observed unless a later line produces
a Kind::Blocked hit, in which case BLOCKED wins and the
function short-circuits — there is nothing a later line could
say that would outrank BLOCKED. This matches the plan’s
“BLOCKED always takes priority” contract and lets the loop
controller drive a single pass without manual priority logic.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scanner
impl RefUnwindSafe for Scanner
impl Send for Scanner
impl Sync for Scanner
impl Unpin for Scanner
impl UnsafeUnpin for Scanner
impl UnwindSafe for Scanner
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more