fixes for pdu error enum
This commit is contained in:
parent
990b8de519
commit
9dfc593d2a
@ -106,7 +106,7 @@ impl EofPdu {
|
|||||||
}
|
}
|
||||||
generic_length_checks_pdu_deserialization(buf, min_expected_len, full_len_without_crc)?;
|
generic_length_checks_pdu_deserialization(buf, min_expected_len, full_len_without_crc)?;
|
||||||
let directive_type = FileDirectiveType::try_from(buf[current_idx]).map_err(|_| {
|
let directive_type = FileDirectiveType::try_from(buf[current_idx]).map_err(|_| {
|
||||||
PduError::InvalidDirectiveType((buf[current_idx], FileDirectiveType::EofPdu))
|
PduError::InvalidDirectiveType((buf[current_idx], Some(FileDirectiveType::EofPdu)))
|
||||||
})?;
|
})?;
|
||||||
if directive_type != FileDirectiveType::EofPdu {
|
if directive_type != FileDirectiveType::EofPdu {
|
||||||
return Err(PduError::WrongDirectiveType((
|
return Err(PduError::WrongDirectiveType((
|
||||||
|
@ -170,7 +170,7 @@ impl<'fs_responses> FinishedPdu<'fs_responses> {
|
|||||||
let min_expected_len = current_idx + 2;
|
let min_expected_len = current_idx + 2;
|
||||||
generic_length_checks_pdu_deserialization(buf, min_expected_len, full_len_without_crc)?;
|
generic_length_checks_pdu_deserialization(buf, min_expected_len, full_len_without_crc)?;
|
||||||
let directive_type = FileDirectiveType::try_from(buf[current_idx]).map_err(|_| {
|
let directive_type = FileDirectiveType::try_from(buf[current_idx]).map_err(|_| {
|
||||||
PduError::InvalidDirectiveType((buf[current_idx], FileDirectiveType::FinishedPdu))
|
PduError::InvalidDirectiveType((buf[current_idx], Some(FileDirectiveType::FinishedPdu)))
|
||||||
})?;
|
})?;
|
||||||
if directive_type != FileDirectiveType::FinishedPdu {
|
if directive_type != FileDirectiveType::FinishedPdu {
|
||||||
return Err(PduError::WrongDirectiveType((
|
return Err(PduError::WrongDirectiveType((
|
||||||
|
@ -248,7 +248,7 @@ impl<'src_name, 'dest_name, 'opts> MetadataPdu<'src_name, 'dest_name, 'opts> {
|
|||||||
}
|
}
|
||||||
generic_length_checks_pdu_deserialization(buf, min_expected_len, full_len_without_crc)?;
|
generic_length_checks_pdu_deserialization(buf, min_expected_len, full_len_without_crc)?;
|
||||||
let directive_type = FileDirectiveType::try_from(buf[current_idx]).map_err(|_| {
|
let directive_type = FileDirectiveType::try_from(buf[current_idx]).map_err(|_| {
|
||||||
PduError::InvalidDirectiveType((buf[current_idx], FileDirectiveType::MetadataPdu))
|
PduError::InvalidDirectiveType((buf[current_idx], Some(FileDirectiveType::MetadataPdu)))
|
||||||
})?;
|
})?;
|
||||||
if directive_type != FileDirectiveType::MetadataPdu {
|
if directive_type != FileDirectiveType::MetadataPdu {
|
||||||
return Err(PduError::WrongDirectiveType((
|
return Err(PduError::WrongDirectiveType((
|
||||||
|
@ -43,8 +43,8 @@ pub enum PduError {
|
|||||||
WrongDirectiveType((FileDirectiveType, FileDirectiveType)),
|
WrongDirectiveType((FileDirectiveType, FileDirectiveType)),
|
||||||
/// The directive type field contained a value not in the range of permitted values.
|
/// The directive type field contained a value not in the range of permitted values.
|
||||||
/// The first tuple entry will be the found raw number, the second entry the expected entry
|
/// The first tuple entry will be the found raw number, the second entry the expected entry
|
||||||
/// type.
|
/// type when applicable.
|
||||||
InvalidDirectiveType((u8, FileDirectiveType)),
|
InvalidDirectiveType((u8, Option<FileDirectiveType>)),
|
||||||
/// Invalid condition code. Contains the raw detected value.
|
/// Invalid condition code. Contains the raw detected value.
|
||||||
InvalidConditionCode(u8),
|
InvalidConditionCode(u8),
|
||||||
/// Invalid checksum type which is not part of the checksums listed in the
|
/// Invalid checksum type which is not part of the checksums listed in the
|
||||||
@ -101,8 +101,7 @@ impl Display for PduError {
|
|||||||
PduError::InvalidDirectiveType((found, expected)) => {
|
PduError::InvalidDirectiveType((found, expected)) => {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"invalid directive type value {found}, expected {expected:?} ({})",
|
"invalid directive type value {found}, expected {expected:?}"
|
||||||
*expected as u8
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
PduError::InvalidChecksumType(checksum_type) => {
|
PduError::InvalidChecksumType(checksum_type) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user