VrtPacket

Struct VrtPacket 

Source
pub struct VrtPacket<'a> {
    pub header: Header,
    pub stream_id: Option<u32>,
    pub class_id: Option<ClassId>,
    pub tsi: Option<u32>,
    pub tsf: Option<u64>,
    pub payload: &'a [u8],
    pub trailer: Option<Trailer>,
}
Expand description

VRT Packet

Fields§

§header: Header

VRT Packet Header

§stream_id: Option<u32>

Optional Stream Id

§class_id: Option<ClassId>

Optional Class Id

§tsi: Option<u32>

Optional Integer-Seconds Timestamp

§tsf: Option<u64>

Optional Fractional-Seconds Timestamp

§payload: &'a [u8]

Data Payload

§trailer: Option<Trailer>

Optional VRT Packet Trailer

Implementations§

Source§

impl VrtPacket<'_>

Source

pub fn parse(i: &[u8]) -> IResult<&[u8], VrtPacket<'_>>

Parse the VRT packet

Source

pub fn serialize(&mut self, buffer: &mut [u8]) -> Result<usize, Error>

Serialize the VITA-49 packet into the provided buffer.

§Arguments
  • buffer - The buffer to serialize the packet into.
§Returns
  • Ok(usize) - The number of bytes written to the buffer.
  • Err(Error) - An error if the buffer is too small or if serialization fails.
§Example
use vrt::VrtPacket;

let mut packet = VrtPacket::default();
// Set the fields of the packet as needed
// packet.header.packet_type = ...;
let mut buffer = [0u8; 1024]; // Ensure the buffer is large enough

match packet.serialize(&mut buffer) {
   Ok(size) => println!("Serialized {} bytes", size),
   Err(e) => eprintln!("Error: {:?}", e),
}

Trait Implementations§

Source§

impl<'a> Debug for VrtPacket<'a>

Source§

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

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

impl<'a> Default for VrtPacket<'a>

Source§

fn default() -> VrtPacket<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> PartialEq for VrtPacket<'a>

Source§

fn eq(&self, other: &VrtPacket<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for VrtPacket<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for VrtPacket<'a>

§

impl<'a> RefUnwindSafe for VrtPacket<'a>

§

impl<'a> Send for VrtPacket<'a>

§

impl<'a> Sync for VrtPacket<'a>

§

impl<'a> Unpin for VrtPacket<'a>

§

impl<'a> UnwindSafe for VrtPacket<'a>

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.