pub struct MessageView<'a> { /* private fields */ }Expand description
Zero-copy view into a complete SOME/IP message (header + payload).
Implementations§
Source§impl<'a> MessageView<'a>
impl<'a> MessageView<'a>
Sourcepub fn parse(buf: &'a [u8]) -> Result<Self, Error>
pub fn parse(buf: &'a [u8]) -> Result<Self, Error>
Parse a complete SOME/IP message from buf.
Validates the header, checks that the buffer contains enough data for the declared payload, and for SD messages validates SD-specific constraints.
§Errors
Returns an error if the header is invalid, the buffer is too short for the declared payload, or SD-specific validation fails.
Any bytes past the declared payload are silently discarded. Use the
Decode impl’s decode to recover the trailing
bytes (the next message in a multi-message datagram), or
decode_exact to reject them.
This is a thin wrapper over the Decode impl, which is the single
source of decode logic for this type.
Sourcepub fn header(&self) -> HeaderView<'a>
pub fn header(&self) -> HeaderView<'a>
Returns the header view.
Sourcepub fn payload_bytes(&self) -> &'a [u8] ⓘ
pub fn payload_bytes(&self) -> &'a [u8] ⓘ
Returns the raw payload bytes.
Sourcepub fn sd_header(&self) -> Result<SdHeaderView<'a>, Error>
pub fn sd_header(&self) -> Result<SdHeaderView<'a>, Error>
Parse the payload as an SD header.
The caller should check is_sd() first; this method returns an error
if the message is not an SD message (the SD validation in parse must
have already passed).
§Errors
Returns an error if this is not an SD message or the SD payload is malformed.
Trait Implementations§
Source§impl<'a> Clone for MessageView<'a>
impl<'a> Clone for MessageView<'a>
Source§fn clone(&self) -> MessageView<'a>
fn clone(&self) -> MessageView<'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 MessageView<'a>
Source§impl<'a> Debug for MessageView<'a>
impl<'a> Debug for MessageView<'a>
Source§impl<'a> Decode<'a> for MessageView<'a>
impl<'a> Decode<'a> for MessageView<'a>
Source§fn decode(buf: &'a [u8]) -> Result<(Self, &'a [u8]), Error>
fn decode(buf: &'a [u8]) -> Result<(Self, &'a [u8]), Error>
Decode a single SOME/IP message from the front of buf.
Validates the header, checks that the buffer contains enough data for the
declared payload, and for SD messages validates SD-specific constraints.
Returns (message, remaining_bytes), where the remainder is any bytes
past this message’s declared payload (the next message in a
multi-message datagram).
§Errors
Returns an error if the header is invalid, the buffer is too short for the declared payload, or SD-specific validation fails.
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