extended time writer trait
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good

This commit is contained in:
2024-02-05 15:04:29 +01:00
parent 92403738ca
commit d01309cccf
5 changed files with 55 additions and 1 deletions

View File

@ -587,6 +587,10 @@ impl TimeWriter for TimeProviderCcsdsEpoch {
}
Ok(current_idx)
}
fn len_written(&self) -> usize {
self.len_as_bytes()
}
}
impl CcsdsTimeProvider for TimeProviderCcsdsEpoch {
@ -1226,4 +1230,13 @@ mod tests {
panic!("unexpected error: {}", cuc_error);
}
}
#[test]
fn test_stamp_to_vec() {
let stamp = TimeProviderCcsdsEpoch::new_u16_counter(100);
let stamp_vec = stamp.to_vec().unwrap();
let mut buf: [u8; 16] = [0; 16];
stamp.write_to_bytes(&mut buf).unwrap();
assert_eq!(stamp_vec, buf[..stamp.len_written()]);
}
}