Trait SerializableFst

Source
pub trait SerializableFst<W: SerializableSemiring>: ExpandedFst<W> {
    // Required methods
    fn fst_type() -> String;
    fn load(input: &[u8]) -> Result<Self>;
    fn store<O: Write>(&self, output: O) -> Result<()>;
    fn from_parsed_fst_text(parsed_fst_text: ParsedTextFst<W>) -> Result<Self>;

    // Provided methods
    fn read<P: AsRef<Path>>(path_bin_fst: P) -> Result<Self> { ... }
    fn write<P: AsRef<Path>>(&self, path_bin_fst: P) -> Result<()> { ... }
    fn from_text_string(fst_string: &str) -> Result<Self> { ... }
    fn read_text<P: AsRef<Path>>(path_text_fst: P) -> Result<Self> { ... }
    fn write_text<P: AsRef<Path>>(&self, path_output: P) -> Result<()> { ... }
    fn text(&self) -> Result<String> { ... }
    fn draw<P: AsRef<Path>>(
        &self,
        path_output: P,
        config: &DrawingConfig,
    ) -> Result<()> { ... }
}
Expand description

Trait definining the methods an Fst must implement to be serialized and deserialized.

Required Methods§

Source

fn fst_type() -> String

String identifying the type of the FST. Will be used when serialiing and deserializing an FST in binary format.

Source

fn load(input: &[u8]) -> Result<Self>

Loads an FST from the binary format data in a Read.

Source

fn store<O: Write>(&self, output: O) -> Result<()>

Store the FST in binary format to a Write.

Source

fn from_parsed_fst_text(parsed_fst_text: ParsedTextFst<W>) -> Result<Self>

Turns a generic wFST format into the one of the wFST.

Provided Methods§

Source

fn read<P: AsRef<Path>>(path_bin_fst: P) -> Result<Self>

Loads an FST from a file in binary format.

Source

fn write<P: AsRef<Path>>(&self, path_bin_fst: P) -> Result<()>

Writes the FST to a file in binary format.

Source

fn from_text_string(fst_string: &str) -> Result<Self>

Deserializes a wFST in text from a path and returns a loaded wFST.

Source

fn read_text<P: AsRef<Path>>(path_text_fst: P) -> Result<Self>

Deserializes a wFST in text from a path and returns a loaded wFST.

Source

fn write_text<P: AsRef<Path>>(&self, path_output: P) -> Result<()>

Serializes the FST as a text file in a format compatible with OpenFST.

Source

fn text(&self) -> Result<String>

Writes the text representation of the FST into a String.

Source

fn draw<P: AsRef<Path>>( &self, path_output: P, config: &DrawingConfig, ) -> Result<()>

Serializes the FST as a DOT file compatible with GraphViz binaries.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§