Skip to main content

leodos_protocols/transport/cfdp/class2/machine/sender/
event.rs

1use crate::transport::cfdp::class2::machine::PromptType;
2use crate::transport::cfdp::class2::machine::TimerType;
3use crate::transport::cfdp::class2::machine::TransactionId;
4use crate::transport::cfdp::filestore::FileId;
5use crate::transport::cfdp::pdu::EntityId;
6use crate::transport::cfdp::pdu::Pdu;
7use crate::transport::cfdp::pdu::file_directive::metadata::ChecksumType;
8
9/// Represents all possible inputs that can drive the `SenderMachine`.
10#[derive(Debug)]
11pub enum Event<'a> {
12    /// A user request to send a file to a remote entity.
13    PutRequest {
14        /// Filestore identifier for the file on the sending side.
15        source_file_name: FileId,
16        /// Filestore identifier for the file on the receiving side.
17        destination_file_name: FileId,
18        /// The remote entity to send the file to.
19        destination_id: EntityId,
20        /// Total size of the file being transferred in bytes.
21        file_size: u64,
22        /// Algorithm used to verify file integrity.
23        checksum_type: ChecksumType,
24    },
25    /// A user request to prompt the receiver for a NAK or Keep Alive response.
26    PromptRequest {
27        /// Identifies the transaction to send the prompt for.
28        transaction_id: TransactionId,
29        /// Whether to prompt for a NAK or Keep Alive response.
30        prompt_type: PromptType,
31    },
32    /// A user request to suspend a transaction.
33    SuspendRequest {
34        /// Identifies the transaction to suspend.
35        transaction_id: TransactionId,
36    },
37    /// A user request to resume a suspended transaction.
38    ResumeRequest {
39        /// Identifies the transaction to resume.
40        transaction_id: TransactionId,
41    },
42    /// A PDU has been received from a remote entity for a transaction this machine is handling.
43    PduReceived {
44        /// Identifies the transaction the received PDU belongs to.
45        transaction_id: TransactionId,
46        /// The received protocol data unit to process.
47        pdu: &'a Pdu,
48    },
49    /// A timer, previously requested via an `Action`, has expired.
50    TimerExpired {
51        /// Identifies the transaction the expired timer belongs to.
52        transaction_id: TransactionId,
53        /// The kind of timer that expired.
54        timer_type: TimerType,
55    },
56    /// A chunk of file data, requested via a `RequestFileData` action, is ready to be sent.
57    DataSegmentReady {
58        /// Identifies the transaction the data belongs to.
59        transaction_id: TransactionId,
60        /// The file data segment payload.
61        data: &'a [u8],
62        /// Byte offset within the file where this data begins.
63        offset: u64,
64    },
65    /// The checksum calculation, requested via an `Action`, has completed.
66    ChecksumReady {
67        /// Identifies the transaction the checksum was computed for.
68        transaction_id: TransactionId,
69        /// The computed checksum value.
70        checksum: u32,
71    },
72}