pub struct Pdu { /* private fields */ }Expand description
A zero-copy view of a generic CFDP PDU, containing the header and raw bytes.
+—————————————+—————+ | Field Name | Size | +—————————————+—————+ | – PDU Header (Variable Length) —– | ———–– | | | | | – Fixed Part (4 bytes) ———–– | ———–– | | | | | Version Number | 3 bits | | PDU Type | 1 bit | | Direction | 1 bit | | Transmission Mode | 1 bit | | CRC Flag | 1 bit | | Large File Flag | 1 bit | | | | | PDU Data Field Length | 16 bits | | | | | Segmentation Control | 1 bit | | Length of Entity IDs | 3 bits | | Segment Metadata Flag | 1 bit | | Length of Transaction Sequence Number | 3 bits | | | | | – Variable Part (3 to 24 bytes) –– | ———–– | | | | | Source Entity ID | 1 to 8 octets | | Transaction Sequence Number | 1 to 8 octets | | Destination Entity ID | 1 to 8 octets | | | | +—————————————+—————+ | – PDU Data Field (Variable Length) - | ———–– | | | | +—————————————+—————+
Implementations§
Source§impl Pdu
impl Pdu
Sourcepub fn header(&self) -> &PduHeaderFixedPart
pub fn header(&self) -> &PduHeaderFixedPart
Returns the fixed part of the header.
Sourcepub fn header_mut(&mut self) -> &mut PduHeaderFixedPart
pub fn header_mut(&mut self) -> &mut PduHeaderFixedPart
Returns a mutable reference to the fixed part of the header.
Sourcepub fn variant(&self) -> Result<PduVariant<'_>, CfdpError>
pub fn variant(&self) -> Result<PduVariant<'_>, CfdpError>
Parses the PDU data field into a typed PduVariant.
Sourcepub fn set_header(&mut self, header: PduHeaderFixedPart)
pub fn set_header(&mut self, header: PduHeaderFixedPart)
Sets the fixed part of the header.
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Returns the total length of the PDU header (fixed + variable parts).
Sourcepub fn source_entity_id(&self) -> Result<EntityId, CfdpError>
pub fn source_entity_id(&self) -> Result<EntityId, CfdpError>
Parses and returns a slice for the source entity ID.
Sourcepub fn set_source_entity_id(
&mut self,
source_entity_id: EntityId,
) -> Result<(), CfdpError>
pub fn set_source_entity_id( &mut self, source_entity_id: EntityId, ) -> Result<(), CfdpError>
Writes the source entity ID into the variable header.
Sourcepub fn transaction_seq_num(&self) -> Result<TransactionSeqNum, CfdpError>
pub fn transaction_seq_num(&self) -> Result<TransactionSeqNum, CfdpError>
Parses and returns a slice for the transaction sequence number.
Sourcepub fn set_transaction_seq_num(
&mut self,
txn_seq_num: TransactionSeqNum,
) -> Result<(), CfdpError>
pub fn set_transaction_seq_num( &mut self, txn_seq_num: TransactionSeqNum, ) -> Result<(), CfdpError>
Writes the transaction sequence number into the variable header.
Sourcepub fn set_destination_entity_id(
&mut self,
dest_entity_id: EntityId,
) -> Result<(), CfdpError>
pub fn set_destination_entity_id( &mut self, dest_entity_id: EntityId, ) -> Result<(), CfdpError>
Parses and returns a slice for the destination entity ID.
Sourcepub fn data_field(&self) -> Result<&[u8], CfdpError>
pub fn data_field(&self) -> Result<&[u8], CfdpError>
Returns a slice representing the PDU’s data field.
Sourcepub fn data_field_mut(&mut self) -> Result<&mut [u8], CfdpError>
pub fn data_field_mut(&mut self) -> Result<&mut [u8], CfdpError>
Returns a mutable slice representing the PDU’s data field.
Methods from Deref<Target = PduHeaderFixedPart>§
Sourcepub fn set_version(&mut self, version: u8)
pub fn set_version(&mut self, version: u8)
Sets the 3-bit CFDP version number.
Sourcepub fn set_pdu_type(&mut self, pdu_type: PduType)
pub fn set_pdu_type(&mut self, pdu_type: PduType)
Sets the PDU type field.
Sourcepub fn set_direction(&mut self, direction: Direction)
pub fn set_direction(&mut self, direction: Direction)
Sets the direction field.
Sourcepub fn tx_mode(&self) -> TransmissionMode
pub fn tx_mode(&self) -> TransmissionMode
Returns the transmission mode (Acknowledged or Unacknowledged).
Sourcepub fn set_tx_mode(&mut self, tx_mode: TransmissionMode)
pub fn set_tx_mode(&mut self, tx_mode: TransmissionMode)
Sets the transmission mode field.
Sourcepub fn set_crc_flag(&mut self, crc_flag: bool)
pub fn set_crc_flag(&mut self, crc_flag: bool)
Sets the CRC flag.
Sourcepub fn large_file_flag(&self) -> bool
pub fn large_file_flag(&self) -> bool
Returns true if this is a large-file transaction (64-bit offsets).
Sourcepub fn set_large_file_flag(&mut self, large_file_flag: bool)
pub fn set_large_file_flag(&mut self, large_file_flag: bool)
Sets the large file flag.
Sourcepub fn data_field_len(&self) -> usize
pub fn data_field_len(&self) -> usize
Returns the length of the PDU data field in bytes.
Sourcepub fn set_data_field_len(&mut self, len: u16)
pub fn set_data_field_len(&mut self, len: u16)
Sets the PDU data field length.
Sourcepub fn segmentation_control(&self) -> bool
pub fn segmentation_control(&self) -> bool
Returns the segmentation control flag.
Sourcepub fn set_segmentation_control(&mut self, seg_ctrl: bool)
pub fn set_segmentation_control(&mut self, seg_ctrl: bool)
Sets the segmentation control flag.
Sourcepub fn entity_id_len(&self) -> usize
pub fn entity_id_len(&self) -> usize
Returns the length of entity IDs in bytes (1 to 8).
Sourcepub fn set_entity_id_len(&mut self, len: usize) -> Result<(), CfdpError>
pub fn set_entity_id_len(&mut self, len: usize) -> Result<(), CfdpError>
Sets the entity ID length (must be 1 to 8).
Sourcepub fn segment_metadata_flag(&self) -> bool
pub fn segment_metadata_flag(&self) -> bool
Returns the segment metadata flag.
Sourcepub fn set_segment_metadata_flag(&mut self, seg_meta_flag: bool)
pub fn set_segment_metadata_flag(&mut self, seg_meta_flag: bool)
Sets the segment metadata flag.
Sourcepub fn txn_seq_num_len(&self) -> usize
pub fn txn_seq_num_len(&self) -> usize
Returns the length of the transaction sequence number in bytes.
Sourcepub fn set_txn_seq_num_len(&mut self, len: usize) -> Result<(), CfdpError>
pub fn set_txn_seq_num_len(&mut self, len: usize) -> Result<(), CfdpError>
Sets the transaction sequence number length (must be 1 to 8).
Sourcepub fn fixed_header_len(&self) -> usize
pub fn fixed_header_len(&self) -> usize
Returns the size of the fixed header portion in bytes.
Sourcepub fn variable_header_len(&self) -> usize
pub fn variable_header_len(&self) -> usize
Calculates the length of the variable-sized portion of the PDU header
Sourcepub fn total_header_len(&self) -> usize
pub fn total_header_len(&self) -> usize
Returns the total header length (fixed + variable parts).
Sourcepub fn total_pdu_len(&self) -> usize
pub fn total_pdu_len(&self) -> usize
Returns the total PDU length (header + data field).
Trait Implementations§
Source§impl FromBytes for Pduwhere
PduHeaderFixedPart: FromBytes,
[u8]: FromBytes,
impl FromBytes for Pduwhere
PduHeaderFixedPart: FromBytes,
[u8]: FromBytes,
§fn ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
fn ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
§fn ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
fn ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
§fn ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: Immutable + KnownLayout,
fn ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: Immutable + KnownLayout,
&Self. Read more§fn mut_from_bytes(
source: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_bytes(
source: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
§fn mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
§fn mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
§fn ref_from_bytes_with_elems(
source: &[u8],
count: usize,
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
fn ref_from_bytes_with_elems(
source: &[u8],
count: usize,
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
§fn ref_from_prefix_with_elems(
source: &[u8],
count: usize,
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
fn ref_from_prefix_with_elems(
source: &[u8],
count: usize,
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
§fn ref_from_suffix_with_elems(
source: &[u8],
count: usize,
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
fn ref_from_suffix_with_elems(
source: &[u8],
count: usize,
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
§fn mut_from_bytes_with_elems(
source: &mut [u8],
count: usize,
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout<PointerMetadata = usize> + Immutable,
fn mut_from_bytes_with_elems(
source: &mut [u8],
count: usize,
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout<PointerMetadata = usize> + Immutable,
§fn mut_from_prefix_with_elems(
source: &mut [u8],
count: usize,
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout<PointerMetadata = usize>,
fn mut_from_prefix_with_elems(
source: &mut [u8],
count: usize,
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout<PointerMetadata = usize>,
§fn mut_from_suffix_with_elems(
source: &mut [u8],
count: usize,
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout<PointerMetadata = usize>,
fn mut_from_suffix_with_elems(
source: &mut [u8],
count: usize,
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout<PointerMetadata = usize>,
Source§impl FromZeros for Pduwhere
PduHeaderFixedPart: FromZeros,
[u8]: FromZeros,
impl FromZeros for Pduwhere
PduHeaderFixedPart: FromZeros,
[u8]: FromZeros,
Source§impl IntoBytes for Pdu
impl IntoBytes for Pdu
§fn as_mut_bytes(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
fn as_mut_bytes(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
§fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
Source§impl KnownLayout for Pduwhere
[u8]: KnownLayout,
impl KnownLayout for Pduwhere
[u8]: KnownLayout,
Source§type PointerMetadata = <[u8] as KnownLayout>::PointerMetadata
type PointerMetadata = <[u8] as KnownLayout>::PointerMetadata
Self. Read more§fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>
fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>
Self with the given pointer
metadata. Read moreSource§impl TryFromBytes for Pduwhere
PduHeaderFixedPart: TryFromBytes,
[u8]: TryFromBytes,
impl TryFromBytes for Pduwhere
PduHeaderFixedPart: TryFromBytes,
[u8]: TryFromBytes,
§fn try_ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
§fn try_ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
§fn try_ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
§fn try_mut_from_bytes(
bytes: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_bytes(
bytes: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
§fn try_mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
§fn try_mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
§fn try_ref_from_bytes_with_elems(
source: &[u8],
count: usize,
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
fn try_ref_from_bytes_with_elems(
source: &[u8],
count: usize,
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
§fn try_ref_from_prefix_with_elems(
source: &[u8],
count: usize,
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
fn try_ref_from_prefix_with_elems(
source: &[u8],
count: usize,
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
source as a &Self with
a DST length equal to count. Read more§fn try_ref_from_suffix_with_elems(
source: &[u8],
count: usize,
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
fn try_ref_from_suffix_with_elems(
source: &[u8],
count: usize,
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + Immutable,
source as a &Self with
a DST length equal to count. Read more§fn try_mut_from_bytes_with_elems(
source: &mut [u8],
count: usize,
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
fn try_mut_from_bytes_with_elems(
source: &mut [u8],
count: usize,
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
§fn try_mut_from_prefix_with_elems(
source: &mut [u8],
count: usize,
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
fn try_mut_from_prefix_with_elems(
source: &mut [u8],
count: usize,
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
source as a &mut Self
with a DST length equal to count. Read more§fn try_mut_from_suffix_with_elems(
source: &mut [u8],
count: usize,
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
fn try_mut_from_suffix_with_elems(
source: &mut [u8],
count: usize,
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout<PointerMetadata = usize> + IntoBytes,
source as a &mut Self
with a DST length equal to count. Read more