Struct levenshtein_automata::DFA [] [src]

pub struct DFA { /* fields omitted */ }

Implementation of a Deterministic Finite Automaton for a Levenshtein Automaton targeting UTF-8 encoded strings.

The automaton does not validate utf-8. It will not return errors when fed with invalid utf-8

The only sink state is guaranteed to be SINK.

This means that if you reach the sink state you are guaranteed that regardless of the sequence of bytes you might consume in the future, you will always remain in the same state.

This property can be exploited to abort further evaluation.

Usage

let mut state = dfa.initial_state();
for &byte in str.as_bytes() {
    state = dfa.transition(state, byte);
    if state == SINK_STATE {
        break;
    }
}
let distance = dfa.distance(state);

Methods

impl DFA
[src]

[src]

Returns the initial state

[src]

Helper function that consumes all of the bytes a sequence of bytes and returns the resulting distance.

[src]

Returns the Levenshtein distance associated to the current state.

[src]

Returns the number of states in the DFA.

[src]

Returns the destination state reached after consuming a given byte.

Trait Implementations

Auto Trait Implementations

impl Send for DFA

impl Sync for DFA