this can not really be deserialized
Some checks failed
Rust/spacepackets/pipeline/head There was a failure building this commit
Rust/spacepackets/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Robin Müller 2023-12-06 17:33:28 +01:00
parent 28e9dd9b29
commit d472c8476a
Signed by: muellerr
GPG Key ID: A649FB78196E3849
2 changed files with 2 additions and 17 deletions

View File

@ -34,12 +34,12 @@ pub enum FileStatus {
///
/// For more information, refer to CFDP chapter 5.2.3.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct FinishedPduCreator<'fs_responses> {
pdu_header: PduHeader,
condition_code: ConditionCode,
delivery_code: DeliveryCode,
file_status: FileStatus,
#[cfg_attr(feature = "serde", serde(borrow))]
fs_responses:
&'fs_responses [FilestoreResponseTlv<'fs_responses, 'fs_responses, 'fs_responses>],
fault_location: Option<EntityIdTlv>,
@ -637,19 +637,4 @@ mod tests {
let finished_pdu_deserialized = FinishedPduReader::from_bytes(&finished_pdu_vec).unwrap();
assert_eq!(finished_pdu_deserialized, finished_pdu);
}
#[test]
#[cfg(feature = "serde")]
fn test_finished_serialization_serde() {
let finished_pdu = generic_finished_pdu(
CrcFlag::NoCrc,
LargeFileFlag::Normal,
DeliveryCode::Complete,
FileStatus::Retained,
);
let output = to_allocvec(&finished_pdu).unwrap();
let output_converted_back: FinishedPduCreator = from_bytes(&output).unwrap();
assert_eq!(output_converted_back, finished_pdu);
}
}

View File

@ -42,7 +42,7 @@ pub trait GenericTlv {
pub trait WritableTlv {
fn write_to_bytes(&self, buf: &mut [u8]) -> Result<usize, ByteConversionError>;
fn len_written(&self) -> usize;
#[cfg(feautre = "alloc")]
#[cfg(feature = "alloc")]
fn to_vec(&self) -> Vec<u8> {
let mut buf = vec![0; self.len_written()];
self.write_to_bytes(&mut buf).unwrap();