add EcssEnumerationExt trait extension
This commit is contained in:
parent
65e85f20e0
commit
d391891991
@ -1,5 +1,6 @@
|
|||||||
//! Common definitions and helpers required to create PUS TMTC packets according to
|
//! Common definitions and helpers required to create PUS TMTC packets according to
|
||||||
//! [ECSS-E-ST-70-41C](https://ecss.nl/standard/ecss-e-st-70-41c-space-engineering-telemetry-and-telecommand-packet-utilization-15-april-2016/)
|
//! [ECSS-E-ST-70-41C](https://ecss.nl/standard/ecss-e-st-70-41c-space-engineering-telemetry-and-telecommand-packet-utilization-15-april-2016/)
|
||||||
|
use core::fmt::Debug;
|
||||||
use crate::{ByteConversionError, CcsdsPacket, SizeMissmatch};
|
use crate::{ByteConversionError, CcsdsPacket, SizeMissmatch};
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
use crc::{Crc, CRC_16_IBM_3740};
|
use crc::{Crc, CRC_16_IBM_3740};
|
||||||
@ -171,6 +172,8 @@ pub trait EcssEnumeration {
|
|||||||
fn write_to_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError>;
|
fn write_to_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait EcssEnumerationExt: EcssEnumeration + Debug + Copy + Clone + PartialEq + Eq {}
|
||||||
|
|
||||||
pub trait ToBeBytes {
|
pub trait ToBeBytes {
|
||||||
type ByteArray: AsRef<[u8]>;
|
type ByteArray: AsRef<[u8]>;
|
||||||
fn to_be_bytes(&self) -> Self::ByteArray;
|
fn to_be_bytes(&self) -> Self::ByteArray;
|
||||||
@ -208,6 +211,7 @@ impl ToBeBytes for u64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive (Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
pub struct GenericEcssEnumWrapper<TYPE> {
|
pub struct GenericEcssEnumWrapper<TYPE> {
|
||||||
val: TYPE,
|
val: TYPE,
|
||||||
}
|
}
|
||||||
@ -239,6 +243,8 @@ impl<TYPE: ToBeBytes> EcssEnumeration for GenericEcssEnumWrapper<TYPE> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<TYPE: Debug + Copy + Clone + PartialEq + Eq + ToBeBytes> EcssEnumerationExt for GenericEcssEnumWrapper<TYPE> {}
|
||||||
|
|
||||||
pub type EcssEnumU8 = GenericEcssEnumWrapper<u8>;
|
pub type EcssEnumU8 = GenericEcssEnumWrapper<u8>;
|
||||||
pub type EcssEnumU16 = GenericEcssEnumWrapper<u16>;
|
pub type EcssEnumU16 = GenericEcssEnumWrapper<u16>;
|
||||||
pub type EcssEnumU32 = GenericEcssEnumWrapper<u32>;
|
pub type EcssEnumU32 = GenericEcssEnumWrapper<u32>;
|
||||||
|
Loading…
Reference in New Issue
Block a user