1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
use std::fmt::Debug; use crate::algorithms::compose::matchers::MatchType; #[derive(Clone, Debug)] pub struct SMatchInput {} #[derive(Clone, Debug)] pub struct SMatchOutput {} #[derive(Clone, Debug)] pub struct SMatchBoth {} #[derive(Clone, Debug)] pub struct SMatchNone {} #[derive(Clone, Debug)] pub struct SMatchUnknown {} pub trait MatchTypeTrait: Debug + Clone { fn match_type() -> MatchType; } impl MatchTypeTrait for SMatchInput { fn match_type() -> MatchType { MatchType::MatchInput } } impl MatchTypeTrait for SMatchOutput { fn match_type() -> MatchType { MatchType::MatchOutput } } impl MatchTypeTrait for SMatchBoth { fn match_type() -> MatchType { MatchType::MatchBoth } } impl MatchTypeTrait for SMatchNone { fn match_type() -> MatchType { MatchType::MatchNone } } impl MatchTypeTrait for SMatchUnknown { fn match_type() -> MatchType { MatchType::MatchUnknown } } #[derive(Clone, Debug, Copy)] pub enum Selector { Fst1Matcher2, Fst2Matcher1, } pub(crate) fn selector(match_type: MatchType, lookahead_type: MatchType) -> Selector { match match_type { MatchType::MatchInput => Selector::Fst1Matcher2, MatchType::MatchOutput => Selector::Fst2Matcher1, _ => { if lookahead_type == MatchType::MatchOutput { Selector::Fst2Matcher1 } else { Selector::Fst1Matcher2 } } } }