pub struct DestinationHandler<PduSender: PduSendProvider, UserFaultHook: UserFaultHookProvider, Vfs: VirtualFilestore, RemoteCfgTable: RemoteEntityConfigProvider, CheckTimerCreator: TimerCreatorProvider<Countdown = CheckTimerProvider>, CheckTimerProvider: CountdownProvider> {
pub pdu_sender: PduSender,
pub vfs: Vfs,
pub remote_cfg_table: RemoteCfgTable,
pub check_timer_creator: CheckTimerCreator,
/* private fields */
}
alloc
only.Expand description
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 DestinationHandler::state_machine function is the primary function to drive the destination handler. It can be used to insert packets into the destination handler and driving the state machine, which might generate new packets to be sent to the remote entity. 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. All generated packets are sent using the user provided PduSendProvider.
The handler requires the alloc feature but will allocated all required memory on construction time. This means that the handler is still suitable for embedded systems where run-time allocation is prohibited. Furthermore, it uses the VirtualFilestore abstraction to allow usage on systems without a std filesystem.
This handler is able to deal with file copy operations to directories, similarly to how the
UNIX tool cp
works. If the destination path is a directory instead of a regular full path,
the source path base file name will be appended to the destination path to form the resulting
new full path.
in different concurrent contexts. For example, you can dynamically create new handlers and run them inside a thread pool, or move the newly created handler to a new thread.“”“
Fields§
§pdu_sender: PduSender
§vfs: Vfs
§remote_cfg_table: RemoteCfgTable
§check_timer_creator: CheckTimerCreator
Implementations§
Source§impl<PduSender: PduSendProvider, UserFaultHook: UserFaultHookProvider, Vfs: VirtualFilestore, RemoteCfgTable: RemoteEntityConfigProvider, TimerCreator: TimerCreatorProvider<Countdown = Countdown>, Countdown: CountdownProvider> DestinationHandler<PduSender, UserFaultHook, Vfs, RemoteCfgTable, TimerCreator, Countdown>
impl<PduSender: PduSendProvider, UserFaultHook: UserFaultHookProvider, Vfs: VirtualFilestore, RemoteCfgTable: RemoteEntityConfigProvider, TimerCreator: TimerCreatorProvider<Countdown = Countdown>, Countdown: CountdownProvider> DestinationHandler<PduSender, UserFaultHook, Vfs, RemoteCfgTable, TimerCreator, Countdown>
Sourcepub fn new(
local_cfg: LocalEntityConfig<UserFaultHook>,
max_packet_len: usize,
pdu_sender: PduSender,
vfs: Vfs,
remote_cfg_table: RemoteCfgTable,
timer_creator: TimerCreator,
) -> Self
pub fn new( local_cfg: LocalEntityConfig<UserFaultHook>, max_packet_len: usize, pdu_sender: PduSender, vfs: Vfs, remote_cfg_table: RemoteCfgTable, timer_creator: TimerCreator, ) -> Self
Constructs a new destination handler.
§Arguments
local_cfg
- The local CFDP entity configuration.max_packet_len
- The maximum expected generated packet size in bytes. Each time a packet is sent, it will be buffered inside an internal buffer. The length of this buffer will be determined by this parameter. This parameter can either be a known upper bound, or it can specifically be determined by the largest packet size parameter of all remote entity configurations in the passedremote_cfg_table
.pdu_sender
- PduSendProvider used to send generated PDU packets.vfs
- VirtualFilestore implementation used by the handler, which decouples the CFDP implementation from the underlying filestore/filesystem. This allows to use this handler for embedded systems where a standard runtime might not be available.remote_cfg_table
- The RemoteEntityConfigProvider used to look up remote entities and target specific configuration for file copy operations.check_timer_creator
- TimerCreatorProvider used by the CFDP handler to generate timers required by various tasks. This allows to use this handler for embedded systems where the standard time APIs might not be available.
pub fn state_machine_no_packet( &mut self, cfdp_user: &mut impl CfdpUser, ) -> Result<u32, DestError>
Sourcepub fn state_machine(
&mut self,
cfdp_user: &mut impl CfdpUser,
packet_to_insert: Option<&impl PduProvider>,
) -> Result<u32, DestError>
pub fn state_machine( &mut self, cfdp_user: &mut impl CfdpUser, packet_to_insert: Option<&impl PduProvider>, ) -> Result<u32, DestError>
This is the core function to drive the destination handler. It is also used to insert packets into the destination handler.
The state machine should either be called if a packet with the appropriate destination ID is received and periodically to perform all CFDP related tasks, for example checking for timeouts or missed file segments.
The function returns the number of sent PDU packets on success.
Sourcepub fn cancel_request(&mut self, transaction_id: &TransactionId) -> bool
pub fn cancel_request(&mut self, transaction_id: &TransactionId) -> bool
This function models the Cancel.request CFDP primitive and is the recommended way to cancel a transaction. It will cause a Notice Of Cancellation at this entity. Please note that the state machine might still be active because a cancelled transfer might still require some packets to be sent to the remote sender entity.
If no unexpected errors occur, this function returns whether the current transfer was cancelled. It returns false if the state machine is currently idle or if there is a transaction ID missmatch.
Sourcepub fn transmission_mode(&self) -> Option<TransmissionMode>
pub fn transmission_mode(&self) -> Option<TransmissionMode>
Returns None if the state machine is IDLE, and the transmission mode of the current request otherwise.
pub fn transaction_id(&self) -> Option<TransactionId>
pub fn handle_prompt_pdu(&mut self, _raw_packet: &[u8]) -> Result<(), DestError>
Sourcepub fn step(&self) -> TransactionStep
pub fn step(&self) -> TransactionStep
Get the step, which denotes the exact step of a pending CFDP transaction when applicable.
Sourcepub fn state(&self) -> State
pub fn state(&self) -> State
Get the step, which denotes whether the CFDP handler is active, and which CFDP class is used if it is active.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
This function is public to allow completely resetting the handler, but it is explicitely discouraged to do this. CFDP has mechanism to detect issues and errors on itself. Resetting the handler might interfere with these mechanisms and lead to unexpected behaviour.