3 This crate provides a fast implementation of ordered sets and maps using finite
4 state machines. In particular, it makes use of finite state transducers to map
5 keys to values as the machine is executed. Using finite state machines as data
6 structures enables us to store keys in a compact format that is also easily
7 searchable. For example, this crate leverages memory maps to make range queries
10 Check out my blog post
11 [Index 1,600,000,000 Keys with Automata and
12 Rust](http://blog.burntsushi.net/transducers/)
13 for extensive background, examples and experiments.
15 [![Build status](https://github.com/BurntSushi/fst/workflows/ci/badge.svg)](https://github.com/BurntSushi/fst/actions)
16 [![](http://meritbadge.herokuapp.com/fst)](https://crates.io/crates/fst)
18 Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org).
26 [`regex-automata`](https://docs.rs/regex-automata)
27 crate provides implementations of the `fst::Automata` trait when its
28 `transducer` feature is enabled. This permits using DFAs compiled by
29 `regex-automata` to search finite state transducers produced by this crate.
34 Simply add a corresponding entry to your `Cargo.toml` dependency list:
44 This example demonstrates building a set in memory and executing a fuzzy query
45 against it. You'll need `fst = "0.4"` with the `levenshtein` feature enabled in
49 use fst::{IntoStreamer, Set};
50 use fst::automaton::Levenshtein;
52 fn main() -> Result<(), Box<dyn std::error::Error>> {
53 // A convenient way to create sets in memory.
54 let keys = vec!["fa", "fo", "fob", "focus", "foo", "food", "foul"];
55 let set = Set::from_iter(keys)?;
57 // Build our fuzzy query.
58 let lev = Levenshtein::new("foo", 1)?;
60 // Apply our fuzzy query to the set we built.
61 let stream = set.search(lev).into_stream();
63 let keys = stream.into_strs()?;
64 assert_eq!(keys, vec!["fo", "fob", "foo", "food"]);
69 Check out the documentation for a lot more examples!
74 * `levenshtein` - **Disabled** by default. This adds the `Levenshtein`
75 automaton to the `automaton` sub-module. This includes an additional
76 dependency on `utf8-ranges`.