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
impl<'a, TAlphabet, TState, TOutput> Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output,
[src]
impl<'a, TAlphabet, TState, TOutput> Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output,
[src]pub fn current_state(&self) -> State
[src]
pub fn current_state(&self) -> State
[src]Get the current state in the automaton that this query is at.
pub fn go_to_state(&mut self, state: State)
[src]
pub fn go_to_state(&mut self, state: State)
[src]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!
pub fn has_transition_on(&self, input: &TAlphabet) -> bool
[src]
pub fn has_transition_on(&self, input: &TAlphabet) -> bool
[src]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.
pub fn next(&mut self, input: &TAlphabet) -> Option<&'a TOutput>
[src]
pub fn next(&mut self, input: &TAlphabet) -> Option<&'a TOutput>
[src]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.
pub fn current_state_data(&self) -> Option<&'a TState>
[src]
pub fn current_state_data(&self) -> Option<&'a TState>
[src]Get the current state’s associated custom data, if any.
See also
InsertionBuilder::set_state_data
.
pub fn is_in_final_state(&self) -> bool
[src]
pub fn is_in_final_state(&self) -> bool
[src]Is this query currently in a final state?
pub fn finish(self) -> Option<&'a TOutput>
[src]
pub fn finish(self) -> Option<&'a TOutput>
[src]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
impl<'a, TAlphabet: Clone, TState: Clone, TOutput: Clone> Clone for Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output,
[src]
impl<'a, TAlphabet: Clone, TState: Clone, TOutput: Clone> Clone for Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output,
[src]Auto Trait Implementations
impl<'a, TAlphabet, TState, TOutput> RefUnwindSafe for Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: RefUnwindSafe,
TOutput: RefUnwindSafe,
TState: RefUnwindSafe,
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,
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,
TAlphabet: Sync,
TOutput: Sync,
TState: Sync,
impl<'a, TAlphabet, TState, TOutput> Unpin for Query<'a, TAlphabet, TState, TOutput>
impl<'a, TAlphabet, TState, TOutput> UnwindSafe for Query<'a, TAlphabet, TState, TOutput> where
TAlphabet: RefUnwindSafe,
TOutput: RefUnwindSafe,
TState: RefUnwindSafe,
TAlphabet: RefUnwindSafe,
TOutput: RefUnwindSafe,
TState: RefUnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more