update LV and TLV code #22

Merged
muellerr merged 10 commits from update-lv-tlv into main 2023-08-17 21:33:49 +02:00
2 changed files with 4 additions and 8 deletions
Showing only changes of commit 9a52066314 - Show all commits

View File

@ -269,10 +269,7 @@ impl<'data> TryFrom<Tlv<'data>> for EntityIdTlv {
}
}
let len_value = value.value().len();
if len_value != 1
&& len_value != 2
&& len_value != 4
&& len_value != 8 {
if len_value != 1 && len_value != 2 && len_value != 4 && len_value != 8 {
return Err(TlvLvError::InvalidValueLength(len_value));
}
Ok(Self::new(

View File

@ -1,7 +1,7 @@
//! Abstractions for the Message to User CFDP TLV subtype.
use delegate::delegate;
use super::{Tlv, TlvLvError, TlvType, TlvTypeField};
use crate::ByteConversionError;
use super::{TlvLvError, Tlv, TlvType, TlvTypeField};
use delegate::delegate;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct MsgToUserTlv<'data> {
@ -9,11 +9,10 @@ pub struct MsgToUserTlv<'data> {
}
impl<'data> MsgToUserTlv<'data> {
/// Create a new message to user TLV where the type field is set correctly.
pub fn new(value: &'data [u8]) -> Result<MsgToUserTlv<'data>, TlvLvError> {
Ok(Self {
tlv: Tlv::new(TlvType::MsgToUser, value)?
tlv: Tlv::new(TlvType::MsgToUser, value)?,
})
}