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>
impl<T: AsRef<[u8]>> Packet<T>
Sourcepub const fn new_unchecked(buffer: T) -> Packet<T>
pub const fn new_unchecked(buffer: T) -> Packet<T>
Sourcepub fn new_checked(buffer: T) -> Result<Packet<T>>
pub fn new_checked(buffer: T) -> Result<Packet<T>>
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
Checks the length of the packet.
§Returns
Result<()>- Ok if the length is valid, otherwise an error.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Sourcepub fn reserved(&self) -> u32
pub fn reserved(&self) -> u32
Returns the Reserved field (3 bytes, should be 0x000000)
§Returns
u32- The Reserved field (only uses lower 24 bits)
Sourcepub fn entries_length(&self) -> usize
pub fn entries_length(&self) -> usize
Returns the Length of Entries Array (4 bytes)
§Returns
usize- The length of the entries array in bytes
Sourcepub fn entries_array(&self) -> &[u8]
pub fn entries_array(&self) -> &[u8]
Sourcepub fn options_length(&self) -> usize
pub fn options_length(&self) -> usize
Returns the Length of Options Array (4 bytes)
§Returns
usize- The length of the options array in bytes
Sourcepub fn options_array(&self) -> &[u8]
pub fn options_array(&self) -> &[u8]
Sourcepub fn total_length(&self) -> usize
pub fn total_length(&self) -> usize
Source§impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T>
impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T>
Sourcepub fn set_reserved(&mut self, reserved: u32)
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)
Sourcepub fn set_entries_length(&mut self, length: u32)
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
Sourcepub fn entries_array_mut(&mut self) -> &mut [u8]
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
Sourcepub fn set_options_length(&mut self, length: u32)
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
Sourcepub fn options_array_mut(&mut self) -> &mut [u8]
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§
impl<T: Eq + AsRef<[u8]>> Eq for Packet<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more