Struct peepmatic_automata::Query [−][src]
pub struct Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output, { /* fields omitted */ }
Expand description
A low-level query of an Automaton
.
This allows you to incrementally query an Automaton
, without providing the
full input sequence ahead of time, and also to incrementally build up the
output.
The typical usage pattern is:
-
First, a series of
next
calls that each provide one character of the input sequence.If this query is still on a path towards a known entry of the automata, then
Some
is returned with the partial output of the transition that was just taken. Otherwise,None
is returned, signifying that the input string has been rejected by the automata.You may also inspect the current state’s associated custom data, if any, in between
next
calls via thecurrent_state_data
method. -
When the input sequence is exhausted, call
is_in_final_state
to determine if this query is in a final state of the automata. If it is not, then the input string has been rejected by the automata. -
Given that the input sequence is exhausted, you may call
finish
to get the final bit of partial output.
Implementations
Get the current state in the automaton that this query is at.
Move this query to the given state in the automaton.
This can be used to implement backtracking, if you can also reset your
output to the way it was when you previously visited the given State
.
Only use a State
that came from this query’s automaton! Mixing and
matching states between automata will result in bogus results and/or
panics!
Does the query’s current state have a transition on the given input?
Regardless whether a transition on the given input exists for the current state or not, the query remains in the current state.
Transition to the next state given the next input character, and return the partial output for that transition.
If None
is returned, then the input sequence has been rejected by the
automata, and this query remains in its current state.
Get the current state’s associated custom data, if any.
See also
InsertionBuilder::set_state_data
.
Is this query currently in a final state?
Given that the input sequence is exhausted, get the final bit of partial output.
Returns None
if this query is not currently in a final state, meaning
that the automata has rejected this input sequence. You can check
whether that is the case or not with the
is_in_final_state
method.
Trait Implementations
Auto Trait Implementations
impl<'a, TAlphabet, TState, TOutput> RefUnwindSafe for Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: RefUnwindSafe,
TOutput: RefUnwindSafe,
TState: RefUnwindSafe,
impl<'a, TAlphabet, TState, TOutput> Send for Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: Sync,
TOutput: Sync,
TState: Sync,
impl<'a, TAlphabet, TState, TOutput> Sync for Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: Sync,
TOutput: Sync,
TState: Sync,
impl<'a, TAlphabet, TState, TOutput> UnwindSafe for Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: RefUnwindSafe,
TOutput: RefUnwindSafe,
TState: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more