DestinationHandler

Struct DestinationHandler 

Source
pub struct DestinationHandler<PduSenderInstance: PduSender, UserFaultHookInstance: UserFaultHook, VirtualFileStoreInstance: VirtualFilestore, RemoteConfigStoreInstance: RemoteConfigStore, TimerCreatorInstance: TimerCreator<Countdown = CountdownInstance>, CountdownInstance: Countdown, LostSegmentTracker: LostSegmentStore> {
    pub pdu_sender: PduSenderInstance,
    pub vfs: VirtualFileStoreInstance,
    pub remote_cfg_table: RemoteConfigStoreInstance,
    pub check_timer_creator: TimerCreatorInstance,
    /* private fields */
}
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 PduSender.

The handler has an internal buffer for PDU generation and checksum generation. The size of this buffer is select via Cargo features and defaults to 2048 bytes. It does not allocate memory during run-time and thus is suitable for embedded systems where allocation is not possible. 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: PduSenderInstance§vfs: VirtualFileStoreInstance§remote_cfg_table: RemoteConfigStoreInstance§check_timer_creator: TimerCreatorInstance

Implementations§

Source§

impl<PduSenderInstance: PduSender, UserFaultHookInstance: UserFaultHook> DestinationHandler<PduSenderInstance, UserFaultHookInstance, NativeFilestore, RemoteConfigStoreStd, StdTimerCreator, StdCountdown, LostSegmentsList>

Source

pub fn new_std( local_cfg: LocalEntityConfig<UserFaultHookInstance>, pdu_sender: PduSenderInstance, ) -> Self

Available on crate feature std only.
Source§

impl<PduSenderInstance: PduSender, UserFaultHookInstance: UserFaultHook, VirtualFilestoreInstance: VirtualFilestore, RemoteConfigStoreInstance: RemoteConfigStore, TimerCreatorInstance: TimerCreator<Countdown = CountdownInstance>, CountdownInstance: Countdown, LostSegmentTracker: LostSegmentStore> DestinationHandler<PduSenderInstance, UserFaultHookInstance, VirtualFilestoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker>

Source

pub fn new( local_cfg: LocalEntityConfig<UserFaultHookInstance>, pdu_sender: PduSenderInstance, vfs: VirtualFilestoreInstance, remote_cfg_table: RemoteConfigStoreInstance, timer_creator: TimerCreatorInstance, lost_segment_tracker: LostSegmentTracker, ) -> Self

Constructs a new destination handler.

§Arguments
  • local_cfg - The local CFDP entity configuration.

  • pdu_and_cksum_buf_size - The handler requires a buffer to generate PDUs and perform checksum calculations. This parameter can either be a known upper bound for the packet size, for example 2048 or 4096 bytes. It can also specifically be determined by the largest packet size parameter of all remote entity configurations in the passed remote_cfg_table.

  • pdu_sender - PduSender 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 RemoteConfigStore used to look up remote entities and target specific configuration for file copy operations.

  • check_timer_creator - TimerCreator 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.

Source

pub fn state_machine_no_packet( &mut self, cfdp_user: &mut impl CfdpUser, ) -> Result<u32, DestError>

Source

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.

Source

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.

Source

pub fn transmission_mode(&self) -> Option<TransmissionMode>

Returns None if the state machine is IDLE, and the transmission mode of the current request otherwise.

Source

pub fn transaction_id(&self) -> Option<TransactionId>

Source

pub fn step(&self) -> TransactionStep

Get the step, which denotes the exact step of a pending CFDP transaction when applicable.

Source

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.

Source

pub fn local_cfg(&self) -> &LocalEntityConfig<UserFaultHookInstance>

Source

pub fn local_cfg_mut(&mut self) -> &mut LocalEntityConfig<UserFaultHookInstance>

Source

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.

Auto Trait Implementations§

§

impl<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker> !Freeze for DestinationHandler<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker>

§

impl<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker> !RefUnwindSafe for DestinationHandler<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker>

§

impl<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker> Send for DestinationHandler<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker>
where PduSenderInstance: Send, VirtualFileStoreInstance: Send, RemoteConfigStoreInstance: Send, TimerCreatorInstance: Send, LostSegmentTracker: Send, CountdownInstance: Send, UserFaultHookInstance: Send,

§

impl<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker> !Sync for DestinationHandler<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker>

§

impl<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker> Unpin for DestinationHandler<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker>
where PduSenderInstance: Unpin, VirtualFileStoreInstance: Unpin, RemoteConfigStoreInstance: Unpin, TimerCreatorInstance: Unpin, LostSegmentTracker: Unpin, CountdownInstance: Unpin, UserFaultHookInstance: Unpin,

§

impl<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker> UnwindSafe for DestinationHandler<PduSenderInstance, UserFaultHookInstance, VirtualFileStoreInstance, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, LostSegmentTracker>
where PduSenderInstance: UnwindSafe, VirtualFileStoreInstance: UnwindSafe, RemoteConfigStoreInstance: UnwindSafe, TimerCreatorInstance: UnwindSafe, LostSegmentTracker: UnwindSafe, CountdownInstance: UnwindSafe, UserFaultHookInstance: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.