Skip to main content

leodos_protocols/transport/cfdp/pdu/tlv/
entity_id.rs

1use zerocopy::FromBytes;
2use zerocopy::Immutable;
3use zerocopy::IntoBytes;
4use zerocopy::KnownLayout;
5use zerocopy::Unaligned;
6
7use crate::transport::cfdp::CfdpError;
8use crate::transport::cfdp::pdu::EntityId;
9
10/// A zero-copy view of the Value of an Entity ID TLV.
11#[repr(C)]
12#[derive(Debug, FromBytes, IntoBytes, Unaligned, KnownLayout, Immutable)]
13pub struct TlvEntityId {
14    /// The variable-length entity ID bytes.
15    rest: [u8],
16}
17
18impl TlvEntityId {
19    /// Parses and returns the entity ID from the TLV value.
20    pub fn id(&self) -> Result<EntityId, CfdpError> {
21        EntityId::from_bytes(&self.rest)
22    }
23}