add a few owned converters
This commit is contained in:
parent
92a7bcdc12
commit
e0cd096460
@ -358,7 +358,7 @@ impl EntityIdTlv {
|
||||
Ok(Self { entity_id })
|
||||
}
|
||||
|
||||
/// Convert to a generic [Tlv], which also erases the programmatic type information.
|
||||
/// Convert to a generic [Tlv], which also erases the type information.
|
||||
pub fn to_tlv(self, buf: &mut [u8]) -> Result<Tlv, ByteConversionError> {
|
||||
Self::len_check(buf)?;
|
||||
self.entity_id
|
||||
@ -369,6 +369,11 @@ impl EntityIdTlv {
|
||||
_ => panic!("unexpected TLV error"),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub fn to_owned(&self) -> TlvOwned {
|
||||
TlvOwned::new(TlvType::EntityId, &self.entity_id.to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
impl WritableTlv for EntityIdTlv {
|
||||
@ -612,6 +617,11 @@ impl<'first_name, 'second_name> FilestoreRequestTlv<'first_name, 'second_name> {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub fn to_owned(&self) -> TlvOwned {
|
||||
TlvOwned::new(TlvType::FilestoreRequest, &self.to_vec()[2..])
|
||||
}
|
||||
}
|
||||
|
||||
impl WritableTlv for FilestoreRequestTlv<'_, '_> {
|
||||
@ -797,6 +807,11 @@ impl<'first_name, 'second_name, 'fs_msg> FilestoreResponseTlv<'first_name, 'seco
|
||||
filestore_message,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub fn to_owned(&self) -> TlvOwned {
|
||||
TlvOwned::new(TlvType::FilestoreResponse, &self.to_vec()[2..])
|
||||
}
|
||||
}
|
||||
|
||||
impl WritableTlv for FilestoreResponseTlv<'_, '_, '_> {
|
||||
|
@ -1,4 +1,6 @@
|
||||
//! Abstractions for the Message to User CFDP TLV subtype.
|
||||
#[cfg(feature = "alloc")]
|
||||
use super::TlvOwned;
|
||||
use super::{GenericTlv, ReadableTlv, Tlv, TlvLvError, TlvType, TlvTypeField, WritableTlv};
|
||||
use crate::ByteConversionError;
|
||||
use delegate::delegate;
|
||||
@ -75,6 +77,11 @@ impl<'data> MsgToUserTlv<'data> {
|
||||
}
|
||||
Ok(msg_to_user)
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub fn to_owned(&self) -> TlvOwned {
|
||||
self.tlv.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl WritableTlv for MsgToUserTlv<'_> {
|
||||
|
Loading…
Reference in New Issue
Block a user