new resultcode module

This commit is contained in:
Robin Müller 2022-11-27 16:47:34 +01:00
parent c00270aa7a
commit 76245cb55f
No known key found for this signature in database
GPG Key ID: BE6480244DFE612C
3 changed files with 38 additions and 0 deletions

View File

@ -29,5 +29,6 @@ pub mod params;
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
pub mod pool;
pub mod pus;
pub mod resultcode;
pub mod seq_count;
pub mod tmtc;

View File

@ -0,0 +1,36 @@
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct ResultU16 {
group_id: u8,
unique_id: u8,
}
impl ResultU16 {
pub const fn const_new(group_id: u8, unique_id: u8) -> Self {
Self {
group_id,
unique_id,
}
}
pub fn raw(&self) -> u16 {
((self.group_id as u16) << 8) | self.unique_id as u16
}
pub fn group_id(&self) -> u8 {
self.group_id
}
pub fn unique_id(&self) -> u8 {
self.unique_id
}
}
#[derive(Debug)]
pub struct ResultU16Ext {
pub name: &'static str,
pub result: ResultU16,
pub info: &'static str,
}
impl ResultU16Ext {
pub const fn const_new(name: &'static str, result: ResultU16, info: &'static str) -> Self {
Self { name, result, info }
}
}

View File

@ -0,0 +1 @@