From ab5c28d304b122872e7415dcb312ae189166d84d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jun 2023 16:51:22 +0200 Subject: [PATCH] finish PDU --- src/cfdp/pdu/finished.rs | 34 ++++++++++++++++++++++++++++++++++ src/cfdp/pdu/mod.rs | 1 + 2 files changed, 35 insertions(+) create mode 100644 src/cfdp/pdu/finished.rs diff --git a/src/cfdp/pdu/finished.rs b/src/cfdp/pdu/finished.rs new file mode 100644 index 0000000..decb0ea --- /dev/null +++ b/src/cfdp/pdu/finished.rs @@ -0,0 +1,34 @@ +use crate::cfdp::pdu::PduHeader; +use crate::cfdp::ConditionCode; +use num_enum::{IntoPrimitive, TryFromPrimitive}; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Copy, Clone, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[repr(u8)] +pub enum DeliveryCode { + Complete = 0, + Incomplete = 1, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[repr(u8)] +pub enum FileStatus { + DiscardDeliberately = 0b00, + DiscardedFsRejection = 0b01, + Retained = 0b10, + Unreported = 0b11, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct FinishPdu<'fs_responses> { + pdu_header: PduHeader, + condition_code: ConditionCode, + delivery_code: DeliveryCode, + file_status: FileStatus, + fs_responses: Optional<&'fs_responses [u8]>, + // fault_location: +} diff --git a/src/cfdp/pdu/mod.rs b/src/cfdp/pdu/mod.rs index bcdc189..638d325 100644 --- a/src/cfdp/pdu/mod.rs +++ b/src/cfdp/pdu/mod.rs @@ -9,6 +9,7 @@ use std::error::Error; pub mod eof; pub mod file_data; +pub mod finished; pub mod metadata; #[derive(Debug, Copy, Clone, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)]