use crate::{message::Action, name::NameType}; use uuid::Uuid; #[derive(Clone, Debug, Eq, Hash)] pub enum Include { All, Just(T), } impl PartialEq for Include { fn eq(&self, other: &Self) -> bool { match self { Include::All => true, Include::Just(data) => match other { Include::All => true, Include::Just(other_data) => data == other_data, }, } } } #[cfg(test)] mod includes { use super::*; #[test] fn does_all_equal_evberything() { let a: Include = Include::All; let b: Include = Include::Just(5); let c: Include = Include::Just(7); assert!(a == a, "all should equal all"); assert!(a == b, "all should equal just"); assert!(b == a, "just should equal all"); assert!(b == b, "same just should equal"); assert!(b != c, "different justs do not equal"); } } #[derive(Clone, Debug)] pub struct Path { pub msg_id: Include, pub doc: Include, pub action: Include, } impl Path { pub fn new(id: Include, doc: Include, action: Include) -> Self { Self { msg_id: id, doc: doc, action: action, } } }