rustfst/algorithms/replace/
config.rs1use crate::Label;
2
3#[derive(PartialOrd, PartialEq, Copy, Clone, Debug, Eq)]
5pub enum ReplaceLabelType {
6 Neither,
8 Input,
10 Output,
12 #[allow(unused)]
13 Both,
15}
16
17#[derive(PartialOrd, PartialEq, Clone, Debug, Eq)]
18pub struct ReplaceFstOptions {
19 pub root: Label,
21 pub call_label_type: ReplaceLabelType,
23 pub return_label_type: ReplaceLabelType,
25 pub call_output_label: Option<Label>,
28 pub return_label: Label,
30}
31
32impl ReplaceFstOptions {
33 pub fn new(root: Label, epsilon_on_replace: bool) -> Self {
34 Self {
35 root,
36 call_label_type: if epsilon_on_replace {
37 ReplaceLabelType::Neither
38 } else {
39 ReplaceLabelType::Input
40 },
41 return_label_type: ReplaceLabelType::Neither,
42 call_output_label: if epsilon_on_replace { Some(0) } else { None },
43 return_label: 0,
44 }
45 }
46}