Trait aho_corasick::Automaton
[−]
[src]
pub trait Automaton: Sized { fn next_state(&self, si: StateIdx, b: u8) -> StateIdx; fn has_match(&self, si: StateIdx, outi: PatIdx) -> bool; fn get_match(&self, si: StateIdx, outi: PatIdx, texti: usize) -> Match; fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize; fn is_skippable(&self) -> bool; fn patterns(&self) -> &[String]; fn pattern(&self, i: usize) -> &str; fn len(&self) -> usize { ... } fn is_empty(&self) -> bool { ... } fn find<'a, 's>(&'a self, s: &'s str) -> Matches<'a, 's, Self> { ... } fn find_overlapping<'a, 's>(&'a self, s: &'s str) -> MatchesOverlapping<'a, 's, Self> { ... } fn stream_find<'a, R: Read>(&'a self, rdr: R) -> StreamMatches<'a, R, Self> { ... } fn stream_find_overlapping<'a, R: Read>(&'a self, rdr: R) -> StreamMatchesOverlapping<'a, R, Self> { ... } }
An abstraction over automatons and their corresponding iterators.
Required Methods
fn next_state(&self, si: StateIdx, b: u8) -> StateIdx
Return the next state given the current state and next character.
fn has_match(&self, si: StateIdx, outi: PatIdx) -> bool
Return true if and only if the given state and current pattern index indicate a match.
fn get_match(&self, si: StateIdx, outi: PatIdx, texti: usize) -> Match
Build a match given the current state, pattern index and input index.
fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize
Attempt to skip through the input.
This returns the index into text
at which the next match attempt
should start. (If no skipping occurred, then the return value should
be equal to at
.)
Finally, if no match is possible, then return text.len()
.
fn is_skippable(&self) -> bool
Returns true if and only if this automaton can skip through the input.
fn patterns(&self) -> &[String]
Returns all of the patterns matched by this automaton.
The order of the patterns is the order in which they were added.
fn pattern(&self, i: usize) -> &str
Returns the pattern indexed at i
.
The index corresponds to the position at which the pattern was added
to the automaton, starting at 0
.
Provided Methods
fn len(&self) -> usize
Return the number of patterns in the automaton.
fn is_empty(&self) -> bool
Returns true if the automaton has no patterns.
fn find<'a, 's>(&'a self, s: &'s str) -> Matches<'a, 's, Self>
Returns an iterator of non-overlapping matches in s
.
fn find_overlapping<'a, 's>(&'a self, s: &'s str) -> MatchesOverlapping<'a, 's, Self>
Returns an iterator of overlapping matches in s
.
fn stream_find<'a, R: Read>(&'a self, rdr: R) -> StreamMatches<'a, R, Self>
Returns an iterator of non-overlapping matches in the given reader.
fn stream_find_overlapping<'a, R: Read>(&'a self, rdr: R) -> StreamMatchesOverlapping<'a, R, Self>
Returns an iterator of overlapping matches in the given reader.
Implementors
impl Automaton for FullAcAutomaton
impl<T: Transitions> Automaton for AcAutomaton<T>