Packet

Struct Packet 

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

A read/write wrapper around a Some/IP packet buffer.

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 message_id(&self) -> MessageId

Returns the Message ID

§Returns
  • MessageId - The Message ID of the packet
Source

pub fn payload_length(&self) -> usize

Returns the Payload Length

§Returns
  • usize - The Payload Length of the packet
Source

pub fn request_id(&self) -> RequestId

Returns the Request ID

§Returns
  • u32 - The Request ID of the packet
Source

pub fn protocol_version(&self) -> u8

Returns the Protocol Version

§Returns
  • u8 - The Protocol Version of the packet
Source

pub fn interface_version(&self) -> u8

Returns the Interface Version

§Returns
  • u8 - The Interface Version of the packet
Source

pub fn message_type(&self) -> u8

Returns the Message Type (raw u8)

§Returns
  • u8 - The raw message type byte from the packet
Source

pub fn return_code(&self) -> u8

Returns the Return Code (raw u8)

§Returns
  • u8 - The raw return code byte from the packet
Source

pub fn payload_data_range(&self) -> Range<usize>

Returns the range of the payload data

§Returns
  • Range<usize> - The range of the payload data.
Source

pub fn payload_data_length(&self) -> usize

Returns the length of the payload data.

§Returns
  • usize - The length of the payload data.
Source§

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

Source

pub fn set_message_id(&mut self, message_id: MessageId)

Sets the Message ID

§Arguments
  • message_id - The new Message ID to set
Source

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

Sets the Payload Length

§Arguments
  • length - The new Payload Length to set
Source

pub fn set_request_id(&mut self, request_id: RequestId)

Sets the Request ID

§Arguments
  • request_id - The new Request ID to set
Source

pub fn set_protocol_version(&mut self, version: u8)

Sets the Protocol Version

§Arguments
  • version - The new Protocol Version to set
Source

pub fn set_interface_version(&mut self, version: u8)

Sets the Interface Version

§Arguments
  • version - The new Interface Version to set
Source

pub fn set_message_type(&mut self, message_type: u8)

Sets the Message Type (raw u8)

§Arguments
  • message_type - The new message type byte to set
Source

pub fn set_return_code(&mut self, return_code: u8)

Sets the Return Code (raw u8)

§Arguments
  • return_code - The new return code byte to set
Source§

impl<'a, T: AsRef<[u8]> + ?Sized> Packet<&'a T>

Source

pub fn payload_data(&self) -> &'a [u8]

Returns a reference to the payload data,

§Returns
  • &'a [u8] - A reference to the payload data.
Source

pub fn entire_message(&self) -> &'a [u8]

Returns a reference to the entire message.

§Returns
  • &'a [u8] - A reference to the entire message.
Source§

impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&'a mut T>

Source

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

Returns a mutable reference to the payload data,

§Returns
  • &'a mut [u8] - A mutable reference to the payload data.
Source

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

Returns a mutable reference to the entire message.

§Returns
  • &'a mut [u8] - A mutable reference to the entire message.

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<'a, T: AsRef<[u8]> + ?Sized> Display for Packet<&'a T>

Source§

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

Formats the packet as a string

§Arguments
  • f - The formatter
§Returns
  • fmt::Result - The result of the formatting
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.