Struct rsonpath_lib::query::automaton::Automaton
source · pub struct Automaton<'q> { /* private fields */ }
Expand description
A minimal, deterministic automaton representing a JSONPath query.
Implementations
sourceimpl<'q> Automaton<'q>
impl<'q> Automaton<'q>
sourcepub fn new(query: &'q JsonPathQuery) -> Self
pub fn new(query: &'q JsonPathQuery) -> Self
Convert a JsonPathQuery
into a minimal deterministic automaton.
sourcepub fn is_empty_query(&self) -> bool
pub fn is_empty_query(&self) -> bool
Returns whether this automaton represents an empty JSONPath query (‘$’).
Examples
let query = JsonPathQuery::parse("$").unwrap();
let automaton = Automaton::new(&query);
assert!(automaton.is_empty_query());
let query = JsonPathQuery::parse("$.a").unwrap();
let automaton = Automaton::new(&query);
assert!(!automaton.is_empty_query());
sourcepub fn rejecting_state(&self) -> State
pub fn rejecting_state(&self) -> State
Returns the rejecting state of the automaton.
The state is defined as the unique state from which there exists no accepting run. If the query automaton reaches this state, the current subtree is guaranteed to have no matches.
sourcepub fn initial_state(&self) -> State
pub fn initial_state(&self) -> State
Returns the initial state of the automaton.
Query execution should start from this state.
sourcepub fn accepting_state(&self) -> State
pub fn accepting_state(&self) -> State
Returns the accepting state of the automaton.
Query execution should treat transitioning into this state as a match.
sourcepub fn is_accepting(&self, state: State) -> bool
pub fn is_accepting(&self, state: State) -> bool
Returns whether the given state is accepting.
Example
let query = JsonPathQuery::parse("$.a").unwrap();
let automaton = Automaton::new(&query);
assert!(automaton.is_accepting(automaton.accepting_state()));
sourcepub fn is_rejecting(&self, state: State) -> bool
pub fn is_rejecting(&self, state: State) -> bool
Returns whether the given state is rejecting, i.e. there exist no accepting runs from it.
Example
let query = JsonPathQuery::parse("$.a").unwrap();
let automaton = Automaton::new(&query);
assert!(automaton.is_rejecting(automaton.rejecting_state()));