Struct fst::automaton::Subsequence [−][src]
pub struct Subsequence<'a> { /* fields omitted */ }
An automaton that matches if the input contains a specific subsequence.
It can be used to build a simple fuzzy-finder.
extern crate fst; use std::error::Error; use fst::{IntoStreamer, Streamer, Set}; use fst::automaton::Subsequence; fn example() -> Result<(), Box<Error>> { let paths = vec!["/home/projects/bar", "/home/projects/foo", "/tmp/foo"]; let set = Set::from_iter(paths)?; // Build our fuzzy query. let subseq = Subsequence::new("hpf"); // Apply our fuzzy query to the set we built. let mut stream = set.search(subseq).into_stream(); let matches = stream.into_strs()?; assert_eq!(matches, vec!["/home/projects/foo"]); Ok(()) }
Methods
impl<'a> Subsequence<'a>
[src]
impl<'a> Subsequence<'a>
pub fn new(subsequence: &'a str) -> Subsequence<'a>
[src]
pub fn new(subsequence: &'a str) -> Subsequence<'a>
Constructs automaton that matches input containing the specified subsequence.
Trait Implementations
impl<'a> Automaton for Subsequence<'a>
[src]
impl<'a> Automaton for Subsequence<'a>
type State = usize
The type of the state used in the automaton.
fn start(&self) -> usize
[src]
fn start(&self) -> usize
Returns a single start state for this automaton. Read more
fn is_match(&self, state: &usize) -> bool
[src]
fn is_match(&self, state: &usize) -> bool
Returns true if and only if state
is a match state.
fn can_match(&self, _: &usize) -> bool
[src]
fn can_match(&self, _: &usize) -> bool
Returns true if and only if state
can lead to a match in zero or more steps. Read more
fn will_always_match(&self, state: &usize) -> bool
[src]
fn will_always_match(&self, state: &usize) -> bool
Returns true if and only if state
matches and must match no matter what steps are taken. Read more
fn accept(&self, state: &usize, byte: u8) -> usize
[src]
fn accept(&self, state: &usize, byte: u8) -> usize
Return the next state given state
and an input.
fn starts_with(self) -> StartsWith<Self> where
Self: Sized,
[src]
fn starts_with(self) -> StartsWith<Self> where
Self: Sized,
Returns an automaton that matches the strings that start with something this automaton matches. Read more
fn union<Rhs: Automaton>(self, rhs: Rhs) -> Union<Self, Rhs> where
Self: Sized,
[src]
fn union<Rhs: Automaton>(self, rhs: Rhs) -> Union<Self, Rhs> where
Self: Sized,
Returns an automaton that matches the strings matched by either this or the other automaton. Read more
fn intersection<Rhs: Automaton>(self, rhs: Rhs) -> Intersection<Self, Rhs> where
Self: Sized,
[src]
fn intersection<Rhs: Automaton>(self, rhs: Rhs) -> Intersection<Self, Rhs> where
Self: Sized,
Returns an automaton that matches the strings matched by both this and the other automaton. Read more
fn complement(self) -> Complement<Self> where
Self: Sized,
[src]
fn complement(self) -> Complement<Self> where
Self: Sized,
Returns an automaton that matches the strings not matched by this automaton. Read more
Auto Trait Implementations
impl<'a> Send for Subsequence<'a>
impl<'a> Send for Subsequence<'a>
impl<'a> Sync for Subsequence<'a>
impl<'a> Sync for Subsequence<'a>