remove duplicate error variant
This commit is contained in:
@ -153,7 +153,6 @@ pub enum RealPfc {
|
||||
pub enum PusError {
|
||||
VersionNotSupported(PusVersion),
|
||||
IncorrectCrc(u16),
|
||||
RawDataTooShort(usize),
|
||||
NoRawData,
|
||||
/// CRC16 needs to be calculated first
|
||||
CrcCalculationMissing,
|
||||
@ -169,12 +168,6 @@ impl Display for PusError {
|
||||
PusError::IncorrectCrc(crc) => {
|
||||
write!(f, "crc16 {crc:#04x} is incorrect")
|
||||
}
|
||||
PusError::RawDataTooShort(size) => {
|
||||
write!(
|
||||
f,
|
||||
"deserialization error, provided raw data with size {size} too short"
|
||||
)
|
||||
}
|
||||
PusError::NoRawData => {
|
||||
write!(f, "no raw data provided")
|
||||
}
|
||||
@ -218,7 +211,11 @@ pub trait PusPacket: CcsdsPacket {
|
||||
|
||||
pub(crate) fn crc_from_raw_data(raw_data: &[u8]) -> Result<u16, PusError> {
|
||||
if raw_data.len() < 2 {
|
||||
return Err(PusError::RawDataTooShort(raw_data.len()));
|
||||
return Err(ByteConversionError::FromSliceTooSmall {
|
||||
found: raw_data.len(),
|
||||
expected: 2,
|
||||
}
|
||||
.into());
|
||||
}
|
||||
Ok(u16::from_be_bytes(
|
||||
raw_data[raw_data.len() - 2..raw_data.len()]
|
||||
@ -254,11 +251,14 @@ pub(crate) fn crc_procedure(
|
||||
pub(crate) fn user_data_from_raw(
|
||||
current_idx: usize,
|
||||
total_len: usize,
|
||||
raw_data_len: usize,
|
||||
slice: &[u8],
|
||||
) -> Result<&[u8], PusError> {
|
||||
match current_idx {
|
||||
_ if current_idx > total_len - 2 => Err(PusError::RawDataTooShort(raw_data_len)),
|
||||
_ if current_idx > total_len - 2 => Err(ByteConversionError::FromSliceTooSmall {
|
||||
found: total_len - 2,
|
||||
expected: current_idx,
|
||||
}
|
||||
.into()),
|
||||
_ => Ok(&slice[current_idx..total_len - 2]),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user