Robin Mueller
de4e6183b3
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
- Add new shared subcrate satrs-shared to split off some shared components not expected to change very often. - Renmame `satrs-core` to `satrs`. It is expected that sat-rs will remain the primary crate, so the core information is superfluous, and core also implies stability, which will not be the case for some time.
38 lines
870 B
Rust
38 lines
870 B
Rust
use derive_new::new;
|
|
use satrs::spacepackets::ByteConversionError;
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
|
pub enum AcsHkIds {
|
|
TestMgmSet = 1,
|
|
}
|
|
|
|
#[derive(Debug, new, Copy, Clone)]
|
|
pub struct HkUniqueId {
|
|
target_id: u32,
|
|
set_id: u32,
|
|
}
|
|
|
|
impl HkUniqueId {
|
|
#[allow(dead_code)]
|
|
pub fn target_id(&self) -> u32 {
|
|
self.target_id
|
|
}
|
|
#[allow(dead_code)]
|
|
pub fn set_id(&self) -> u32 {
|
|
self.set_id
|
|
}
|
|
|
|
pub fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<usize, ByteConversionError> {
|
|
if buf.len() < 8 {
|
|
return Err(ByteConversionError::ToSliceTooSmall {
|
|
found: buf.len(),
|
|
expected: 8,
|
|
});
|
|
}
|
|
buf[0..4].copy_from_slice(&self.target_id.to_be_bytes());
|
|
buf[4..8].copy_from_slice(&self.set_id.to_be_bytes());
|
|
|
|
Ok(8)
|
|
}
|
|
}
|