Skip to main content

UslpTransferFrame

Struct UslpTransferFrame 

Source
pub struct UslpTransferFrame { /* private fields */ }
Expand description

A zero-copy view over a USLP Transfer Frame.

The 7-byte fixed header is followed by a variable-length body containing the VCF Count, optional Insert Zone, Transfer Frame Data Field (TFDF Header + TFDZ), optional OCF, and optional FECF.

Implementations§

Source§

impl UslpTransferFrame

Source

pub const FIXED_HEADER_SIZE: usize = 7

Size of the fixed portion of the primary header (bytes).

Source

pub const MAX_FRAME_SIZE: usize = 65536

Maximum total frame size (16-bit Frame Length field).

Source

pub fn parse(bytes: &[u8]) -> Result<&Self, ParseError>

Parses a byte slice into a USLP Transfer Frame view.

Validates the TFVN (must be 0b1100), the EOFPH flag (truncated frames are not supported), and the Frame Length field consistency with the buffer size.

Source

pub fn header(&self) -> &UslpPrimaryHeaderFixed

Returns a reference to the fixed primary header.

Source

pub fn header_mut(&mut self) -> &mut UslpPrimaryHeaderFixed

Returns a mutable reference to the fixed primary header.

Source

pub fn body(&self) -> &[u8]

Returns the complete body after the 7-byte fixed header.

Contains VCF Count + Insert Zone + TFDF + OCF + FECF.

Source

pub fn body_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the body.

Source

pub fn primary_header_size(&self) -> usize

Total size of the primary header including VCF Count.

Source

pub fn vcf_count(&self) -> u64

Returns the VCF Count value (big-endian, 0-56 bits).

Source

pub fn set_vcf_count(&mut self, count: u64)

Sets the VCF Count value (big-endian).

Source

pub fn insert_zone(&self, insert_zone_len: usize) -> &[u8]

Returns the Insert Zone slice.

insert_zone_len is a managed parameter configured for the Physical Channel (0 if no Insert Zone).

Source

pub fn insert_zone_mut(&mut self, insert_zone_len: usize) -> &mut [u8]

Returns a mutable reference to the Insert Zone.

Source

pub fn data_field(&self, insert_zone_len: usize, fecf_present: bool) -> &[u8]

Returns the Transfer Frame Data Field (TFDF Header + TFDZ).

insert_zone_len is the managed Insert Zone size. fecf_present indicates whether a 2-byte FECF is appended.

Source

pub fn data_field_mut( &mut self, insert_zone_len: usize, fecf_present: bool, ) -> &mut [u8]

Returns a mutable reference to the data field.

Source

pub fn tfdz_rule(&self, insert_zone_len: usize) -> TfdzRule

Returns the TFDZ Construction Rule from the TFDF Header.

Source

pub fn upid(&self, insert_zone_len: usize) -> u8

Returns the UPID from the TFDF Header.

Source

pub fn pointer(&self, insert_zone_len: usize) -> Option<u16>

Returns the First Header / Last Valid Octet Pointer.

Only present for TFDZ Construction Rules 000, 001, and 010. Returns None if the current rule does not use a pointer.

Source

pub fn data_zone(&self, insert_zone_len: usize, fecf_present: bool) -> &[u8]

Returns the Transfer Frame Data Zone (payload only).

This is the TFDF minus the TFDF Header bytes.

Source

pub fn ocf(&self, fecf_present: bool) -> Option<&[u8]>

Returns the OCF (4 bytes) if present.

Source

pub fn fecf(&self, fecf_present: bool) -> Option<&[u8]>

Returns the FECF (2 bytes) if present.

fecf_present is a managed parameter for the Physical Channel.

Source

pub fn set_tfdf_header( &mut self, insert_zone_len: usize, rule: TfdzRule, upid: u8, pointer: Option<u16>, )

Writes the TFDF Header at the start of the data field.

Sets the Construction Rule, UPID, and optional 16-bit pointer in the TFDF Header bytes.

Source

pub fn builder<'f1>() -> UslpTransferFrameBuilder<'f1>

Constructs a new USLP Transfer Frame in the provided buffer.

The frame length is determined by the buffer size. The body after the primary header is zeroed; use Self::body_mut, Self::set_tfdf_header, and Self::data_field_mut to fill in the Insert Zone, TFDF, OCF, and FECF.

Trait Implementations§

Source§

impl Debug for UslpTransferFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromBytes for UslpTransferFrame
where UslpPrimaryHeaderFixed: FromBytes, [u8]: FromBytes,

§

fn ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout + Immutable,

Interprets the given source as a &Self. Read more
§

fn ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout + Immutable,

Interprets the prefix of the given source as a &Self without copying. Read more
§

fn ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: Immutable + KnownLayout,

Interprets the suffix of the given bytes as a &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,

Interprets the given source as a &mut Self. Read more
§

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,

Interprets the prefix of the given source as a &mut Self without copying. Read more
§

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,

Interprets the suffix of the given source as a &mut Self without copying. Read more
§

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,

Interprets the given source as a &Self with a DST length equal to count. Read more
§

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,

Interprets the prefix of the given source as a DST &Self with length equal to count. Read more
§

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,

Interprets the suffix of the given source as a DST &Self with length equal to count. Read more
§

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,

Interprets the given source as a &mut Self with a DST length equal to count. Read more
§

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>,

Interprets the prefix of the given source as a &mut Self with DST length equal to count. Read more
§

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>,

Interprets the suffix of the given source as a &mut Self with DST length equal to count. Read more
Source§

impl FromZeros for UslpTransferFrame
where UslpPrimaryHeaderFixed: FromZeros, [u8]: FromZeros,

§

fn zero(&mut self)

Overwrites self with zeros. Read more
Source§

impl IntoBytes for UslpTransferFrame
where UslpPrimaryHeaderFixed: IntoBytes, [u8]: IntoBytes,

§

fn as_bytes(&self) -> &[u8]
where Self: Immutable,

Gets the bytes of this value. Read more
§

fn as_mut_bytes(&mut self) -> &mut [u8]
where Self: FromBytes,

Gets the bytes of this value mutably. Read more
§

fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to dst. Read more
§

fn write_to_prefix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the prefix of dst. Read more
§

fn write_to_suffix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the suffix of dst. Read more
Source§

impl KnownLayout for UslpTransferFrame
where [u8]: KnownLayout,

Source§

type PointerMetadata = <[u8] as KnownLayout>::PointerMetadata

The type of metadata stored in a pointer to Self. Read more
§

fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>

Computes the size of an object of type Self with the given pointer metadata. Read more
Source§

impl TryFromBytes for UslpTransferFrame
where UslpPrimaryHeaderFixed: 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,

Attempts to interpret the given source as a &Self. Read more
§

fn try_ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the prefix of the given source as a &Self. Read more
§

fn try_ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the suffix of the given source as a &Self. Read more
§

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,

Attempts to interpret the given source as a &mut Self without copying. Read more
§

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,

Attempts to interpret the prefix of the given source as a &mut Self. Read more
§

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,

Attempts to interpret the suffix of the given source as a &mut Self. Read more
§

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,

Attempts to interpret the given source as a &Self with a DST length equal to count. Read more
§

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,

Attempts to interpret the prefix of the given 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,

Attempts to interpret the suffix of the given 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,

Attempts to interpret the given source as a &mut Self with a DST length equal to count. Read more
§

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,

Attempts to interpret the prefix of the given 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,

Attempts to interpret the suffix of the given source as a &mut Self with a DST length equal to count. Read more
Source§

impl Immutable for UslpTransferFrame
where UslpPrimaryHeaderFixed: Immutable, [u8]: Immutable,

Source§

impl Unaligned for UslpTransferFrame

Auto Trait Implementations§

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