From cc680dba46144c3538df31d17ad80ddd3a9e4141 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 3 Sep 2022 16:28:11 +0200 Subject: [PATCH] timestamp writer should return timestamp error too --- src/time.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/time.rs b/src/time.rs index 5ca4819..c2392b3 100644 --- a/src/time.rs +++ b/src/time.rs @@ -71,7 +71,7 @@ pub const fn ccsds_to_unix_days(ccsds_days: i32) -> i32 { } pub trait TimeWriter { - fn write_to_bytes(&self, bytes: &mut [u8]) -> Result<(), PacketError>; + fn write_to_bytes(&self, bytes: &mut [u8]) -> Result<(), TimestampError>; } pub trait TimeReader { @@ -194,12 +194,14 @@ impl CcsdsTimeProvider for CdsShortTimeProvider { } impl TimeWriter for CdsShortTimeProvider { - fn write_to_bytes(&self, buf: &mut [u8]) -> Result<(), PacketError> { + fn write_to_bytes(&self, buf: &mut [u8]) -> Result<(), TimestampError> { if buf.len() < self.len_as_bytes() { - return Err(PacketError::ToBytesSliceTooSmall(SizeMissmatch { - expected: self.len_as_bytes(), - found: buf.len(), - })); + return Err(TimestampError::OtherPacketError( + PacketError::ToBytesSliceTooSmall(SizeMissmatch { + expected: self.len_as_bytes(), + found: buf.len(), + }), + )); } buf[0] = self.pfield; buf[1..3].copy_from_slice(self.ccsds_days.to_be_bytes().as_slice());