starAndHonor/fst/automaton does not have a README file

    Automaton

    pub(open) trait Automaton {
    fn start(Self) -> Int
    fn accept(Self, Int, Byte) -> Int
    fn is_match(Self, Int) -> Bool
    fn can_match(Self, Int) -> Bool
    fn will_always_match(Self, Int) -> Bool
    fn accept_eof(Self, Int) -> Int?
    }

    A deterministic byte automaton. State -1 is the rejecting sink. Implementations must keep state identities stable throughout a traversal. can_match and will_always_match are conservative pruning promises. accept_eof optionally substitutes the state when a key ends.

    AutomatonError

    pub(all) suberror AutomatonError {
    InvalidArgument(String)
    StateLimit(limit~ : Int)
    WorkLimit(limit~ : Int)
    InvalidState(Int)
    DuplicateTransition(state~ : Int, byte~ : Int)
    } derive(Eq,
    Debug
    )

    AutomatonError::equal

    AutomatonError::not_equal

    fn AutomatonError::not_equal(x : AutomatonError, y : AutomatonError) -> Bool

    DfaBuilder

    pub struct DfaBuilder {
    // private fields
    }

    Builds a deterministic byte automaton. Missing edges go to the rejecting sink. Build takes a snapshot, so later builder edits cannot alter searches.

    DfaBuilder::add_range

    fn DfaBuilder::add_range(self : DfaBuilder, from : Int, lower : Byte, upper : Byte, to : Int) -> Unit raise AutomatonError

    DfaBuilder::add_state

    fn DfaBuilder::add_state(self : DfaBuilder, accepting : Bool) -> Int raise AutomatonError

    DfaBuilder::add_transition

    fn DfaBuilder::add_transition(self : DfaBuilder, from : Int, byte : Byte, to : Int) -> Unit raise AutomatonError

    Adds a deterministic edge. Existing edges are rejected instead of silently replacing a previous rule. A failed range insertion makes no edits.

    DfaBuilder::build

    fn DfaBuilder::build(self : DfaBuilder) -> Matcher raise AutomatonError

    DfaBuilder::new

    fn DfaBuilder::new(max_states? : Int) -> DfaBuilder raise AutomatonError

    DfaBuilder::remove_transition

    fn DfaBuilder::remove_transition(self : DfaBuilder, from : Int, byte : Byte) -> Unit raise AutomatonError

    DfaBuilder::set_eof

    fn DfaBuilder::set_eof(self : DfaBuilder, from : Int, to : Int?) -> Unit raise AutomatonError

    EOF is a single substitution, not an epsilon closure. None keeps the current state. This supports constructs whose acceptance depends on EOF.

    DfaBuilder::set_match

    fn DfaBuilder::set_match(self : DfaBuilder, state : Int, accepting : Bool) -> Unit raise AutomatonError

    DfaBuilder::set_start

    fn DfaBuilder::set_start(self : DfaBuilder, state : Int) -> Unit raise AutomatonError

    DfaBuilder::state_count

    fn DfaBuilder::state_count(self : DfaBuilder) -> Int

    LevenshteinStats

    pub(all) struct LevenshteinStats {
    scalar_states : Int
    utf8_states : Int
    alphabet_classes : Int
    query_scalars : Int
    dp_cells : Int
    } derive(Eq,
    Debug
    )

    LevenshteinStats::equal

    LevenshteinStats::not_equal

    fn LevenshteinStats::not_equal(x : LevenshteinStats, y : LevenshteinStats) -> Bool

    Matcher

    pub struct Matcher {
    // private fields
    }

    Immutable, shareable automata. All transition state is carried by the Int32 supplied by the caller; a matcher never builds caches during a search.

    Matcher::accept

    fn Matcher::accept(self : Matcher, state : Int, byte : Byte) -> Int

    Matcher::accept_eof

    fn Matcher::accept_eof(self : Matcher, state : Int) -> Int?

    Matcher::can_match

    fn Matcher::can_match(self : Matcher, state : Int) -> Bool

    Matcher::is_match

    fn Matcher::is_match(self : Matcher, state : Int) -> Bool

    Matcher::levenshtein_stats

    fn Matcher::levenshtein_stats(self : Matcher) -> LevenshteinStats?

    Matcher::matches

    fn Matcher::matches(self : Matcher, key : Bytes) -> Bool

    Matcher::matches_string

    fn Matcher::matches_string(self : Matcher, key : String) -> Bool

    Matcher::start

    fn Matcher::start(self : Matcher) -> Int

    Matcher::state_count

    fn Matcher::state_count(self : Matcher) -> Int

    Number of state IDs reserved by this matcher's arithmetic encoding.

    Matcher::will_always_match

    fn Matcher::will_always_match(self : Matcher, state : Int) -> Bool

    accepts

    fn accepts(automaton : &Automaton, key : Bytes) -> Bool

    Runs an automaton on one key, including its optional EOF transition.

    always

    fn always() -> Matcher

    byte_length

    fn byte_length(minimum : Int, maximum? : Int, max_states? : Int) -> Matcher raise AutomatonError

    Constrains byte length. An absent maximum accepts all lengths >= minimum.

    byte_range

    fn byte_range(lower : Byte, upper : Byte) -> Matcher raise AutomatonError

    Accepts exactly one byte in the inclusive range.

    complement

    fn complement(inner : Matcher, max_states? : Int) -> Matcher raise AutomatonError

    default_state_limit

    let default_state_limit : Int

    Maximum number of representable states for composed matchers. Constructors reject a product before its Int32 state encoding can overflow.

    dfa_from_table

    fn dfa_from_table(initial : Int, transitions : Array[Array[Int]], accepting : Array[Bool], eof? : Array[Int?], max_states? : Int) -> Matcher raise AutomatonError

    Imports a dense DFA table. Each row must have exactly 256 destinations; -1 denotes an absent edge. Input arrays are copied and fully validated.

    exact

    fn exact(pattern : String) -> Matcher

    Exact UTF-8 byte matching; no normalization or case folding is applied.

    exact_bytes

    fn exact_bytes(pattern : Bytes) -> Matcher

    intersection

    fn intersection(left : Matcher, right : Matcher, max_states? : Int) -> Matcher raise AutomatonError

    levenshtein

    fn levenshtein(query : String, distance : Int, max_states? : Int, max_work? : Int) -> Matcher raise AutomatonError

    Matches valid UTF-8 keys within a Unicode-scalar Levenshtein distance. Insertions, deletions and substitutions cost one; transposition is not a primitive edit. No normalization or case folding is performed.

    Construction eagerly builds a finite scalar DFA and a strict UTF-8 classifier. Equal query scalars share a symbol and every other scalar is equivalent, so runtime accepts bytes without allocating or caching states. max_states bounds the full product of these two machines. max_work bounds the number of DP cells evaluated during construction. Exceeding either limit returns a typed error before a partial matcher can escape.

    never

    fn never() -> Matcher

    prefix

    fn prefix(pattern : String) -> Matcher

    prefix_bytes

    fn prefix_bytes(pattern : Bytes) -> Matcher

    starts_with

    fn starts_with(inner : Matcher, max_states? : Int) -> Matcher raise AutomatonError

    Accepts a key if any prefix, including the empty prefix, matches inner.

    subsequence

    fn subsequence(pattern : String) -> Matcher

    Subsequence matching follows fst's byte semantics, including for UTF-8.

    subsequence_bytes

    fn subsequence_bytes(pattern : Bytes) -> Matcher

    Matches a byte subsequence, preserving order but permitting gaps.

    union

    fn union(left : Matcher, right : Matcher, max_states? : Int) -> Matcher raise AutomatonError