use std::fmt;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Origin {
Inbound,
Outbound,
}
impl Origin {
pub fn is_inbound(&self) -> bool {
matches!(self, Self::Inbound)
}
pub fn is_outbound(&self) -> bool {
matches!(self, Self::Outbound)
}
}
impl fmt::Display for Origin {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Origin::Inbound => f.write_str("inbound"),
Origin::Outbound => f.write_str("outbound"),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn is_api() {
let mut origin = Origin::Inbound;
assert!(origin.is_inbound());
origin = Origin::Outbound;
assert!(origin.is_outbound());
}
#[test]
fn display() {
assert_eq!(&Origin::Inbound.to_string(), "inbound");
assert_eq!(&Origin::Outbound.to_string(), "outbound");
}
}