[][src]Struct fst::automaton::Str

pub struct Str<'a> { /* fields omitted */ }

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 std::error::Error;

use fst::{Automaton, IntoStreamer, Streamer, Set};
use fst::automaton::Str;

fn example() -> Result<(), Box<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(())
}

Methods

impl<'a> Str<'a>[src]

pub fn new(string: &'a str) -> Str<'a>[src]

Constructs automaton that matches an exact string.

Trait Implementations

impl<'a> Automaton for Str<'a>[src]

type State = Option<usize>

The type of the state used in the automaton.

fn will_always_match(&self, _state: &Self::State) -> bool[src]

Returns true if and only if state matches and must match no matter what steps are taken. Read more

fn starts_with(self) -> StartsWith<Self> where
    Self: Sized
[src]

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]

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]

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]

Returns an automaton that matches the strings not matched by this automaton. Read more

impl<'a> Clone for Str<'a>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> Debug for Str<'a>[src]

Auto Trait Implementations

impl<'a> Sync for Str<'a>

impl<'a> Unpin for Str<'a>

impl<'a> Send for Str<'a>

impl<'a> UnwindSafe for Str<'a>

impl<'a> RefUnwindSafe for Str<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]