Skip to main content

VectorFst

Struct VectorFst 

Source
pub struct VectorFst<A: Arc> { /* private fields */ }
Expand description

A simple, mutable FST whose states and arcs are stored in standard Vecs.

Implementations§

Source§

impl<A: Arc> VectorFst<A>

Source

pub const STATIC_PROPERTIES: u64

Source

pub fn new() -> Self

Source§

impl<A: Arc> VectorFst<A>

Source

pub fn read<R: Read>( reader: &mut R, opts: &FstReadOptions, ) -> Result<Self, OpenFstError>

Reads a VectorFst from a stream.

Unlike ConstFst, the states and arcs are written field by field rather than as a block of memory, so there is nothing here that could be mapped and nothing that depends on how a struct happens to be laid out.

Source

pub fn write_fst<F: Fst<A>, W: Write>( fst: &F, writer: &mut W, opts: &FstWriteOptions, ) -> Result<(), OpenFstError>

Writes any FST out in this format.

SICADA-DIVERGE: upstream writes a header saying it does not know the state count when the stream cannot seek, then seeks back to correct it when it can. This always counts first; see ConstFst::write_fst, which makes the same trade for the same reason.

Source

pub fn write<W: Write>( &self, writer: &mut W, opts: &FstWriteOptions, ) -> Result<(), OpenFstError>

Writes this FST out.

Trait Implementations§

Source§

impl<A: Clone + Arc> Clone for VectorFst<A>
where A::StateId: Clone,

Source§

fn clone(&self) -> VectorFst<A>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Arc> ContiguousArcsFst<A> for VectorFst<A>

Source§

fn arcs_slice(&self, state: A::StateId) -> &[A]

Returns a contiguous slice of arcs leaving the given state.
Source§

impl<A: Debug + Arc> Debug for VectorFst<A>
where A::StateId: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: Arc> Default for VectorFst<A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<A: Arc> ExpandedFst<A> for VectorFst<A>

Source§

fn num_states(&self) -> usize

Returns the total number of states in the FST.
Source§

impl<A: Arc> Fst<A> for VectorFst<A>

Source§

type StateIter<'a> = VectorFstStateIter<'a, A> where A: 'a

An iterator over the states of the FST.
Source§

type ArcIter<'a> = Cloned<Iter<'a, A>> where A: 'a

An iterator over the outgoing arcs of a state. Clone is required to allow multi-pass algorithms (e.g., matchers in Compose) to save and restore iteration positions effortlessly without C++ Seek or Reset.
Source§

fn start(&self) -> Option<A::StateId>

Returns the initial state ID, or None if the FST is empty.
Source§

fn final_weight(&self, state: A::StateId) -> A::Weight

Returns the final weight of the given state. If the state is not final, this must return Weight::zero().
Source§

fn num_arcs(&self, state: A::StateId) -> usize

Returns the number of arcs leaving the given state.
Source§

fn num_input_epsilons(&self, state: A::StateId) -> usize

Returns the number of input epsilon arcs leaving the given state.
Source§

fn num_output_epsilons(&self, state: A::StateId) -> usize

Returns the number of output epsilon arcs leaving the given state.
Source§

fn num_states_if_known(&self) -> Option<usize>

Returns the number of states if it is finite and can be computed in O(1) time. Otherwise returns None.
Source§

fn properties(&self, mask: u64, test: bool) -> u64

Property bits. If test is false, returns stored properties bits (some possibly unknown). If test is true, computes the properties if they are unknown.
Source§

fn fst_type(&self) -> &str

Returns the name of the FST type (e.g., “vector”, “const”).
Source§

fn input_symbols(&self) -> Option<AtomicRc<SymbolTable>>

Returns the input label symbol table, if any. Using Arc allows cheap sharing across FST operations.
Source§

fn output_symbols(&self) -> Option<AtomicRc<SymbolTable>>

Returns the output label symbol table, if any.
Source§

fn states<'a>(&'a self) -> Self::StateIter<'a>

Returns an iterator over all state IDs in the FST.
Source§

fn arcs<'a>(&'a self, state: A::StateId) -> Self::ArcIter<'a>

Returns an iterator over the outgoing arcs of the given state.
Source§

fn count_states(&self) -> usize

Computes the exact number of states in the FST. If the state count is known in O(1) (i.e. num_states_if_known returns Some), it uses that. Otherwise, it iterates through all states in O(V) time.
Source§

fn count_arcs(&self) -> usize

Computes the exact number of arcs in the FST in O(V) time.
Source§

impl<A: Arc> MutableFst<A> for VectorFst<A>

Source§

fn set_start(&mut self, state: A::StateId)

Sets the initial state. Read more
Source§

fn set_final(&mut self, state: A::StateId, weight: A::Weight)

Sets the final weight of a given state. Setting it to Weight::zero() effectively marks the state as non-final.
Source§

fn set_properties(&mut self, props: u64, mask: u64)

Explicitly updates the properties mask.
Source§

fn add_state(&mut self) -> A::StateId

Adds a new state to the FST and returns its ID.
Source§

fn add_states(&mut self, n: usize)

Adds n new states to the FST.
Source§

fn add_arc(&mut self, state: A::StateId, arc: A)

Adds an outgoing arc to a given state.
Source§

fn arcs_mut(&mut self, state: A::StateId) -> &mut [A]

The arcs leaving state, to be rearranged in place. Read more
Source§

fn delete_arcs_n(&mut self, state: A::StateId, n: usize)

Deletes n outgoing arcs from a given state.
Source§

fn delete_arcs(&mut self, state: A::StateId)

Deletes all outgoing arcs from a given state.
Source§

fn delete_all_states(&mut self)

Deletes all states and arcs, leaving the FST empty.
Source§

fn delete_states(&mut self, dstates: &[A::StateId])

Deletes specific states. Note: This renumbers the remaining states and invalidates existing Arc nextstates.
Source§

fn reserve_states(&mut self, n: usize)

Hints the underlying allocation to reserve space for n total states.
Source§

fn reserve_arcs(&mut self, state: A::StateId, n: usize)

Hints the underlying allocation to reserve space for n arcs on a specific state.
Source§

fn set_input_symbols(&mut self, syms: Option<AtomicRc<SymbolTable>>)

Attaches an input symbol table.
Source§

fn set_output_symbols(&mut self, syms: Option<AtomicRc<SymbolTable>>)

Attaches an output symbol table.
Source§

fn mutable_input_symbols(&mut self) -> Option<&mut SymbolTable>

The input symbol table, to be changed in place. Read more
Source§

fn mutable_output_symbols(&mut self) -> Option<&mut SymbolTable>

The output symbol table, to be changed in place. See mutable_input_symbols.
Source§

fn mutate_arcs<F>(&mut self, state: A::StateId, mutator: F)
where F: FnMut(&mut A),

Rewrites every arc leaving state. Read more

Auto Trait Implementations§

§

impl<A> !Freeze for VectorFst<A>

§

impl<A> RefUnwindSafe for VectorFst<A>

§

impl<A> Send for VectorFst<A>
where Vec<VectorState<A>>: Send, Option<<A as Arc>::StateId>: Send,

§

impl<A> Sync for VectorFst<A>
where Vec<VectorState<A>>: Sync, Option<<A as Arc>::StateId>: Sync,

§

impl<A> Unpin for VectorFst<A>
where Vec<VectorState<A>>: Unpin, Option<<A as Arc>::StateId>: Unpin,

§

impl<A> UnsafeUnpin for VectorFst<A>

§

impl<A> UnwindSafe for VectorFst<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<A, F> VerifyExt<A> for F
where A: Arc, F: Fst<A>,

Source§

fn verify<const P: u64>(self) -> Result<Verified<F, P>, OpenFstError>