SourceHandler

Struct SourceHandler 

Source
pub struct SourceHandler<PduSenderInstance: PduSender, UserFaultHookInstance: UserFaultHook, Vfs: VirtualFilestore, RemoteConfigStoreInstance: RemoteConfigStore, TimerCreatorInstance: TimerCreator<Countdown = CountdownInstance>, CountdownInstance: Countdown, SequenceCounterInstance: SequenceCounter> { /* private fields */ }
Expand description

This is the primary CFDP source handler. It models the CFDP source entity, which is primarily responsible for handling put requests to send files to another CFDP destination entity.

As such, it contains a state machine to perform all operations necessary to perform a source-to-destination file transfer. This class uses the user provides PduSender to send the CFDP PDU packets generated by the state machine.

The following core functions are the primary interface:

  1. Self::put_request can be used to start transactions, most notably to start and perform a Copy File procedure to send a file or to send a Proxy Put Request to request a file.
  2. Self::state_machine is the primary interface to execute an active file transfer. It generates the necessary CFDP PDUs for this process. This method is also used to insert received packets with the appropriate destination ID and target handler type into the state machine.

A put request will only be accepted if the handler is in the idle state.

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 does not support concurrency out of the box. Instead, if concurrent handling is required, it is recommended to create a new handler and run all active handlers inside a thread pool, or move the newly created handler to a new thread.

Implementations§

Source§

impl<PduSenderInstance: PduSender, UserFaultHookInstance: UserFaultHook, Vfs: VirtualFilestore, RemoteConfigStoreInstance: RemoteConfigStore, TimerCreatorInstance: TimerCreator<Countdown = CountdownInstance>, CountdownInstance: Countdown, SequenceCounterInstance: SequenceCounter> SourceHandler<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance>

Source

pub fn new( cfg: LocalEntityConfig<UserFaultHookInstance>, pdu_sender: PduSenderInstance, vfs: Vfs, remote_cfg_table: RemoteConfigStoreInstance, timer_creator: TimerCreatorInstance, seq_count_provider: SequenceCounterInstance, ) -> Self

Creates a new instance of a source handler.

§Arguments
  • cfg - The local entity configuration for this source handler.
  • pdu_sender - PduSender used to send CFDP PDUs generated by the handler.
  • 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.
  • put_request_cacher - The put request cacher is used cache put requests without requiring run-time allocation.
  • remote_cfg_table - The RemoteEntityConfig used to look up remote entities and target specific configuration for file copy operations.
  • 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.
  • seq_count_provider - The SequenceCounter used to generate the TransactionId which contains an incrementing counter.
Source

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

Calls Self::state_machine, without inserting a packet.

Source

pub fn state_machine( &mut self, cfdp_user: &mut impl CfdpUser, pdu: Option<&impl PduProvider>, ) -> Result<u32, SourceError>

This is the core function to drive the source handler. It is also used to insert packets into the source handler.

The state machine should either be called if a packet with the appropriate destination ID is received, or periodically in IDLE periods 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 transaction_id(&self) -> Option<TransactionId>

Source

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

Returns the TransmissionMode for the active file operation.

Source

pub fn step(&self) -> TransactionStep

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

Source

pub fn state(&self) -> State

Source

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

Source

pub fn put_request( &mut self, put_request: &impl ReadablePutRequest, ) -> Result<(), PutRequestError>

This function is used to pass a put request to the source handler, which is also used to start a file copy operation. As such, this function models the Put.request CFDP primtiive.

Please note that the source handler can also process one put request at a time. The caller is responsible of creating a new source handler, one handler can only handle one file copy request at a time.

Source

pub fn cancel_request( &mut self, user: &mut impl CfdpUser, transaction_id: &TransactionId, ) -> Result<bool, SourceError>

This functions models the Cancel.request CFDP primitive and is the recommended way to cancel a transaction.

This method will cause a Notice of Cancellation at this entity if a transaction is active and the passed transaction ID matches the currently active transaction ID. 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 receiver entity.

If not unexpected errors occur, this method returns true if the transfer was cancelled propery and false if there is no transaction active or the passed transaction ID and the active ID do not match.

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.

Source

pub fn notice_of_cancellation( &mut self, user: &mut impl CfdpUser, condition_code: ConditionCode, ) -> Result<u32, SourceError>

Source

pub fn notice_of_suspension(&mut self)

Source

pub fn abandon_transaction(&mut self)

Auto Trait Implementations§

§

impl<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance> !Freeze for SourceHandler<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance>

§

impl<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance> !RefUnwindSafe for SourceHandler<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance>

§

impl<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance> Send for SourceHandler<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance>
where PduSenderInstance: Send, RemoteConfigStoreInstance: Send, Vfs: Send, TimerCreatorInstance: Send, SequenceCounterInstance: Send, CountdownInstance: Send, UserFaultHookInstance: Send,

§

impl<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance> !Sync for SourceHandler<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance>

§

impl<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance> Unpin for SourceHandler<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance>
where PduSenderInstance: Unpin, RemoteConfigStoreInstance: Unpin, Vfs: Unpin, TimerCreatorInstance: Unpin, SequenceCounterInstance: Unpin, CountdownInstance: Unpin, UserFaultHookInstance: Unpin,

§

impl<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance> UnwindSafe for SourceHandler<PduSenderInstance, UserFaultHookInstance, Vfs, RemoteConfigStoreInstance, TimerCreatorInstance, CountdownInstance, SequenceCounterInstance>
where PduSenderInstance: UnwindSafe, RemoteConfigStoreInstance: UnwindSafe, Vfs: UnwindSafe, TimerCreatorInstance: UnwindSafe, SequenceCounterInstance: 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.