From 2213a255088bf945d4a718716a2f500901257ee8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 22 Jul 2023 18:46:12 +0200 Subject: [PATCH] how to best do this.. --- satrs-core/src/cfdp/dest.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/satrs-core/src/cfdp/dest.rs b/satrs-core/src/cfdp/dest.rs index 09e21fa..026ed95 100644 --- a/satrs-core/src/cfdp/dest.rs +++ b/satrs-core/src/cfdp/dest.rs @@ -1,6 +1,5 @@ -use spacepackets::cfdp::{pdu::FileDirectiveType, PduType}; - use super::{State, TransactionStep}; +use spacepackets::cfdp::{pdu::FileDirectiveType, PduType}; pub struct DestinationHandler { step: TransactionStep, @@ -13,8 +12,29 @@ impl DestinationHandler { pdu_type: PduType, pdu_directive: Option, raw_packet: &[u8], - ) { + ) -> Result<(), ()> { + match pdu_type { + PduType::FileDirective => { + if pdu_directive.is_none() { + return Err(()); + } + self.handle_file_directive(pdu_directive.unwrap(), raw_packet) + } + PduType::FileData => self.handle_file_data(raw_packet), + } } + + pub fn handle_file_data(&mut self, raw_packet: &[u8]) -> Result<(), ()> { + Ok(()) + } + pub fn handle_file_directive( + &mut self, + pdu_directive: FileDirectiveType, + raw_packet: &[u8], + ) -> Result<(), ()> { + Ok(()) + } + pub fn state_machine(&mut self) { match self.state { State::Idle => todo!(),