pub struct EntryView<'a>(/* private fields */);Expand description
Zero-copy view into a 16-byte SD entry in a buffer.
Wire layout (16 bytes total):
[0]: entry type[1]:index_first_options_run[2]:index_second_options_run[3]:options_count(packed nibbles)[4..6]:service_id(BE)[6..8]:instance_id(BE)[8]:major_version[9..12]: ttl (24-bit BE)[12..16]:minor_version(BE) for service entries, OR[12..14]counter +[14..16]event_group_idfor eventgroup entries
Implementations§
Source§impl EntryView<'_>
impl EntryView<'_>
Sourcepub fn entry_type(&self) -> Result<EntryType, Error>
pub fn entry_type(&self) -> Result<EntryType, Error>
Sourcepub fn index_first_options_run(&self) -> u8
pub fn index_first_options_run(&self) -> u8
Returns the index of the first options run.
Sourcepub fn index_second_options_run(&self) -> u8
pub fn index_second_options_run(&self) -> u8
Returns the index of the second options run.
Sourcepub fn options_count(&self) -> OptionsCount
pub fn options_count(&self) -> OptionsCount
Returns the packed options count.
Sourcepub fn service_id(&self) -> u16
pub fn service_id(&self) -> u16
Returns the service ID.
Sourcepub fn instance_id(&self) -> u16
pub fn instance_id(&self) -> u16
Returns the instance ID.
Sourcepub fn major_version(&self) -> u8
pub fn major_version(&self) -> u8
Returns the major version.
Sourcepub fn minor_version(&self) -> u32
pub fn minor_version(&self) -> u32
Minor version (only valid for service entries).
Sourcepub fn counter(&self) -> u16
pub fn counter(&self) -> u16
Counter field (only valid for eventgroup entries). Masked to lower 4 bits.
Sourcepub fn event_group_id(&self) -> u16
pub fn event_group_id(&self) -> u16
Event group ID (only valid for eventgroup entries).
Trait Implementations§
impl<'a> Copy for EntryView<'a>
Source§impl<'a> Decode<'a> for EntryView<'a>
impl<'a> Decode<'a> for EntryView<'a>
Source§fn decode(buf: &'a [u8]) -> Result<(Self, &'a [u8]), Self::Error>
fn decode(buf: &'a [u8]) -> Result<(Self, &'a [u8]), Self::Error>
Decode a single 16-byte SD entry from the front of buf.
This is a pure fixed-stride slice: it does NOT validate the entry-type
byte. Validation is deferred to EntryView::entry_type /
EntryView::to_owned (the L2 validation pass), keeping this a lazy
zero-copy view.
§Errors
Returns Incomplete if fewer than
ENTRY_SIZE (16) bytes remain.
§Panics
Cannot panic — take guarantees exactly ENTRY_SIZE bytes.
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 moreSource§impl<'a> DecodeIter<'a> for EntryView<'a>
impl<'a> DecodeIter<'a> for EntryView<'a>
Source§const WIRE_SIZE: Option<usize>
const WIRE_SIZE: Option<usize>
SD entries have a fixed 16-byte (ENTRY_SIZE) stride, enabling
DecodeIterator::remaining_len.
Source§fn decode_next(buf: &'a [u8]) -> Result<Option<(Self, &'a [u8])>, Self::Error>
fn decode_next(buf: &'a [u8]) -> Result<Option<(Self, &'a [u8])>, Self::Error>
Decode the next entry, or Ok(None) at a clean end of buffer.
A partial (non-multiple-of-16) trailing element is surfaced as an
Err rather than silently dropped.
§Errors
Returns Incomplete if a partial
entry remains after a good start.
Source§type Error = Error
type Error = Error
Incomplete so the
fixed-width leaf read helpers lift through ?. As with
Decode::Error, the variable-width helpers return
ReadUintError and need their own From impl.