xio_base_datatypes/
storage_type.rs

1use StorageTypeWithMixed;
2
3#[repr(u8)]
4#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[cfg_attr(
7    feature = "serde",
8    serde(rename_all = "camelCase", deny_unknown_fields)
9)]
10pub enum StorageType {
11    Channel = 0b01,
12    Fixed = 0b10,
13}
14
15pub trait HasStorageType {
16    fn storage_type(&self) -> StorageType;
17}
18
19pub trait IsInStorageType<T> {
20    fn is_in_storage(&self, t: &T) -> bool;
21}
22
23impl<B> IsInStorageType<StorageTypeWithMixed> for B
24where
25    B: HasStorageType,
26{
27    fn is_in_storage(&self, t: &StorageTypeWithMixed) -> bool {
28        match (t, self.storage_type()) {
29            (&StorageTypeWithMixed::ChannelOrFixed, _)
30            | (&StorageTypeWithMixed::Channel, StorageType::Channel)
31            | (&StorageTypeWithMixed::Fixed, StorageType::Fixed) => true,
32            _ => false,
33        }
34    }
35}