From 71ce43eca6b49ab6c2af0eac9f02dc9d9cb6caf7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Dec 2023 16:26:29 +0100 Subject: [PATCH] added some docs --- satrs-core/src/cfdp/dest.rs | 40 ++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/satrs-core/src/cfdp/dest.rs b/satrs-core/src/cfdp/dest.rs index 28ba401..8e5fd5f 100644 --- a/satrs-core/src/cfdp/dest.rs +++ b/satrs-core/src/cfdp/dest.rs @@ -26,17 +26,6 @@ use spacepackets::{ }; use thiserror::Error; -pub struct DestinationHandler { - local_cfg: LocalEntityConfig, - step: TransactionStep, - state: State, - tparams: TransactionParams, - packets_to_send_ctx: PacketsToSendContext, - vfs: Box, - remote_cfg_table: Box, - check_timer_creator: Box, -} - #[derive(Debug, Default)] struct PacketsToSendContext { packet_available: bool, @@ -180,6 +169,33 @@ pub enum DestError { NoRemoteCfgFound(UnsignedByteField), } +/// This is the primary CFDP destination handler. It models the CFDP destination entity, which is +/// primarily responsible for receiving files sent from another CFDP entity. It performs the +/// reception side of File Copy Operations. + +/// The following core functions are the primary interface for interacting with the destination +/// handler: + +/// 1. [DestinationHandler::state_machine]: Can be used to insert packets into the destination +/// handler. Please note that the destination handler can also only process Metadata, EOF and +/// Prompt PDUs in addition to ACK PDUs where the acknowledged PDU is the Finished PDU. +/// 2. [DestinationHandler::get_next_packet]: Retrieve next packet to be sent back to the remote +/// CFDP source entity ID. + +/// A new file transfer (Metadata PDU reception) is only be accepted if the handler is in the +/// IDLE state. Furthermore, packet insertion is not allowed until all packets to send were +/// retrieved after a state machine call. +pub struct DestinationHandler { + local_cfg: LocalEntityConfig, + step: TransactionStep, + state: State, + tparams: TransactionParams, + packets_to_send_ctx: PacketsToSendContext, + vfs: Box, + remote_cfg_table: Box, + check_timer_creator: Box, +} + impl DestinationHandler { pub fn new( local_cfg: LocalEntityConfig, @@ -231,7 +247,7 @@ impl DestinationHandler { self.packets_to_send_ctx.packet_available } - pub fn get_next_packet_to_send( + pub fn get_next_packet( &self, buf: &mut [u8], ) -> Result, DestError> {