Packet

Struct Packet 

Source
pub struct Packet<T: AsRef<[u8]>> { /* private fields */ }
Expand description

A read/write wrapper around a SOME/IP-SD packet buffer.

SOME/IP-SD message format:

  • Flags (1 byte)
  • Reserved (3 bytes)
  • Length of Entries Array (4 bytes)
  • Entries Array (variable)
  • Length of Options Array (4 bytes)
  • Options Array (variable)

Implementations§

Source§

impl<T: AsRef<[u8]>> Packet<T>

Source

pub const fn new_unchecked(buffer: T) -> Packet<T>

Creates a new unchecked Packet.

§Arguments
  • buffer - A buffer containing the packet data.
§Returns
  • Packet - A new Packet instance.
Source

pub fn new_checked(buffer: T) -> Result<Packet<T>>

Creates a new checked Packet.

§Arguments
  • buffer - A buffer containing the packet data.
§Returns
  • Result<Packet> - A new Packet instance if the buffer is valid.
Source

pub fn check_len(&self) -> Result<()>

Checks the length of the packet.

§Returns
  • Result<()> - Ok if the length is valid, otherwise an error.
Source

pub fn into_inner(self) -> T

Returns the inner buffer.

§Returns
  • T - The inner buffer.
Source

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

Returns a reference to the inner buffer.

§Returns
  • &[u8] - A reference to the buffer.
Source

pub fn flags(&self) -> u8

Returns the Flags byte

§Returns
  • u8 - The Flags byte of the packet
Source

pub fn reserved(&self) -> u32

Returns the Reserved field (3 bytes, should be 0x000000)

§Returns
  • u32 - The Reserved field (only uses lower 24 bits)
Source

pub fn entries_length(&self) -> usize

Returns the Length of Entries Array (4 bytes)

§Returns
  • usize - The length of the entries array in bytes
Source

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

Returns the Entries Array

§Returns
  • &[u8] - A slice containing the entries array
Source

pub fn options_length(&self) -> usize

Returns the Length of Options Array (4 bytes)

§Returns
  • usize - The length of the options array in bytes
Source

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

Returns the Options Array

§Returns
  • &[u8] - A slice containing the options array
Source

pub fn total_length(&self) -> usize

Get the total packet length

§Returns
  • usize - The total length of the packet
Source§

impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T>

Source

pub fn set_flags(&mut self, flags: u8)

Sets the Flags byte

§Arguments
  • flags - The flags byte to set
Source

pub fn set_reserved(&mut self, reserved: u32)

Sets the Reserved field (3 bytes, should be 0x000000)

§Arguments
  • reserved - The reserved value (only lower 24 bits used)
Source

pub fn set_entries_length(&mut self, length: u32)

Sets the Length of Entries Array (4 bytes)

§Arguments
  • length - The length of the entries array in bytes
Source

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

Returns a mutable slice to the Entries Array

§Returns
  • &mut [u8] - A mutable slice to write entries data
Source

pub fn set_options_length(&mut self, length: u32)

Sets the Length of Options Array (4 bytes)

§Arguments
  • length - The length of the options array in bytes
Source

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

Returns a mutable slice to the Options Array

§Returns
  • &mut [u8] - A mutable slice to write options data

Trait Implementations§

Source§

impl<T: Clone + AsRef<[u8]>> Clone for Packet<T>

Source§

fn clone(&self) -> Packet<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + AsRef<[u8]>> Debug for Packet<T>

Source§

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

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

impl<T: AsRef<[u8]>> Display for Packet<T>

Source§

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

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

impl<T: PartialEq + AsRef<[u8]>> PartialEq for Packet<T>

Source§

fn eq(&self, other: &Packet<T>) -> 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<T: Eq + AsRef<[u8]>> Eq for Packet<T>

Source§

impl<T: AsRef<[u8]>> StructuralPartialEq for Packet<T>

Auto Trait Implementations§

§

impl<T> Freeze for Packet<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Packet<T>
where T: RefUnwindSafe,

§

impl<T> Send for Packet<T>
where T: Send,

§

impl<T> Sync for Packet<T>
where T: Sync,

§

impl<T> Unpin for Packet<T>
where T: Unpin,

§

impl<T> UnwindSafe for Packet<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.