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
use StorageTypeWithMixed; #[repr(u8)] #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde", serde(rename_all = "camelCase", deny_unknown_fields) )] pub enum StorageType { Channel = 0b01, Fixed = 0b10, } pub trait HasStorageType { fn storage_type(&self) -> StorageType; } pub trait IsInStorageType<T> { fn is_in_storage(&self, t: &T) -> bool; } impl<B> IsInStorageType<StorageTypeWithMixed> for B where B: HasStorageType, { fn is_in_storage(&self, t: &StorageTypeWithMixed) -> bool { match (t, self.storage_type()) { (&StorageTypeWithMixed::ChannelOrFixed, _) | (&StorageTypeWithMixed::Channel, StorageType::Channel) | (&StorageTypeWithMixed::Fixed, StorageType::Fixed) => true, _ => false, } } }