use ifc_model::Value;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum FlowDirection {
Source,
Sink,
SourceAndSink,
NotDefined,
}
impl FlowDirection {
pub(crate) fn parse(value: Option<&Value>) -> Self {
match value {
Some(Value::Enum(name)) => match name.to_ascii_uppercase().as_str() {
"SOURCE" => Self::Source,
"SINK" => Self::Sink,
"SOURCEANDSINK" => Self::SourceAndSink,
_ => Self::NotDefined,
},
_ => Self::NotDefined,
}
}
pub fn emits(self) -> bool {
matches!(self, Self::Source | Self::SourceAndSink)
}
pub fn accepts(self) -> bool {
matches!(self, Self::Sink | Self::SourceAndSink)
}
pub fn is_stated(self) -> bool {
!matches!(self, Self::NotDefined)
}
}