pub struct HeaderView<'a>(/* private fields */);Expand description
Zero-copy view into a 16-byte SOME/IP header in a buffer.
Implementations§
Source§impl<'a> HeaderView<'a>
impl<'a> HeaderView<'a>
Sourcepub fn parse(buf: &'a [u8]) -> Result<(Self, &'a [u8]), Error>
pub fn parse(buf: &'a [u8]) -> Result<(Self, &'a [u8]), Error>
Parse and validate a SOME/IP header from the beginning of buf.
Returns (view, remaining_bytes) on success.
§Errors
Returns an error if buf is shorter than 16 bytes, the protocol version is
not 0x01, the message type byte is unrecognized, or the return code is invalid.
§Panics
Cannot panic — the expect is guarded by a length check above it.
This is a thin wrapper over the Decode impl, which is the single
source of decode logic for this type.
Sourcepub fn message_id(&self) -> MessageId
pub fn message_id(&self) -> MessageId
Returns the message ID (service ID + method ID).
Sourcepub fn request_id(&self) -> u32
pub fn request_id(&self) -> u32
Returns the request ID (client ID + session ID).
Sourcepub fn payload_size(&self) -> usize
pub fn payload_size(&self) -> usize
Returns the payload size in bytes (length - 8).
Sourcepub const fn upper_header_bytes(&self) -> [u8; 8]
pub const fn upper_header_bytes(&self) -> [u8; 8]
Returns header bytes 8..16: the request ID, protocol and interface versions, message type, and return code. E2E Profile 5 with-header CRC covers these bytes.
Sourcepub fn protocol_version(&self) -> u8
pub fn protocol_version(&self) -> u8
Returns the protocol version.
Sourcepub fn interface_version(&self) -> u8
pub fn interface_version(&self) -> u8
Returns the interface version.
Sourcepub fn message_type(&self) -> MessageTypeField
pub fn message_type(&self) -> MessageTypeField
Sourcepub fn return_code(&self) -> ReturnCode
pub fn return_code(&self) -> ReturnCode
Trait Implementations§
Source§impl<'a> Clone for HeaderView<'a>
impl<'a> Clone for HeaderView<'a>
Source§fn clone(&self) -> HeaderView<'a>
fn clone(&self) -> HeaderView<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for HeaderView<'a>
Source§impl<'a> Debug for HeaderView<'a>
impl<'a> Debug for HeaderView<'a>
Source§impl<'a> Decode<'a> for HeaderView<'a>
impl<'a> Decode<'a> for HeaderView<'a>
Source§fn decode(buf: &'a [u8]) -> Result<(Self, &'a [u8]), Error>
fn decode(buf: &'a [u8]) -> Result<(Self, &'a [u8]), Error>
Decode and validate a SOME/IP header from the front of buf.
Returns (view, remaining_bytes) on success.
§Errors
Returns an error if buf is shorter than 16 bytes, the protocol version is
not 0x01, the message type byte is unrecognized, or the return code is invalid.
§Panics
Cannot panic — the expect is guarded by a length check above it.
Source§type Error = Error
type Error = Error
Incomplete and TrailingBytes
so the fixed-width leaf read helpers (read_u8, read_u16_be,
read_array, …) and the decode_exact default lift through ?. Read more