pub struct Str<'a> {
string: &'a [u8],
}
Expand description
An automaton that matches if the input equals to a specific string.
It can be used in combination with StartsWith
to search strings
starting with a given prefix.
extern crate fst;
use fst::{Automaton, IntoStreamer, Streamer, Set};
use fst::automaton::Str;
fn example() -> Result<(), Box<dyn std::error::Error>> {
let paths = vec!["/home/projects/bar", "/home/projects/foo", "/tmp/foo"];
let set = Set::from_iter(paths)?;
// Build our prefix query.
let prefix = Str::new("/home").starts_with();
// Apply our query to the set we built.
let mut stream = set.search(prefix).into_stream();
let matches = stream.into_strs()?;
assert_eq!(matches, vec!["/home/projects/bar", "/home/projects/foo"]);
Ok(())
}
Fields§
§string: &'a [u8]
Implementations§
Trait Implementations§
Source§impl<'a> Automaton for Str<'a>
impl<'a> Automaton for Str<'a>
Source§fn is_match(&self, pos: &Option<usize>) -> bool
fn is_match(&self, pos: &Option<usize>) -> bool
Returns true if and only if
state
is a match state.Source§fn can_match(&self, pos: &Option<usize>) -> bool
fn can_match(&self, pos: &Option<usize>) -> bool
Returns true if and only if
state
can lead to a match in zero or more
steps. Read moreSource§fn accept(&self, pos: &Option<usize>, byte: u8) -> Option<usize>
fn accept(&self, pos: &Option<usize>, byte: u8) -> Option<usize>
Return the next state given
state
and an input.Source§fn will_always_match(&self, _state: &Self::State) -> bool
fn will_always_match(&self, _state: &Self::State) -> bool
Returns true if and only if
state
matches and must match no matter
what steps are taken. Read moreSource§fn accept_eof(&self, _: &Self::State) -> Option<Self::State>
fn accept_eof(&self, _: &Self::State) -> Option<Self::State>
If applicable, return the next state when the end of a key is seen.
Source§fn starts_with(self) -> StartsWith<Self>where
Self: Sized,
fn starts_with(self) -> StartsWith<Self>where
Self: Sized,
Returns an automaton that matches the strings that start with something
this automaton matches.
Source§fn union<Rhs: Automaton>(self, rhs: Rhs) -> Union<Self, Rhs>where
Self: Sized,
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.
Source§fn intersection<Rhs: Automaton>(self, rhs: Rhs) -> Intersection<Self, Rhs>where
Self: Sized,
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.
Source§fn complement(self) -> Complement<Self>where
Self: Sized,
fn complement(self) -> Complement<Self>where
Self: Sized,
Returns an automaton that matches the strings not matched by this
automaton.
Auto Trait Implementations§
impl<'a> Freeze for Str<'a>
impl<'a> RefUnwindSafe for Str<'a>
impl<'a> Send for Str<'a>
impl<'a> Sync for Str<'a>
impl<'a> Unpin for Str<'a>
impl<'a> UnwindSafe for Str<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more