Skip to main content

EntryView

Struct EntryView 

Source
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_id for eventgroup entries

Implementations§

Source§

impl EntryView<'_>

Source

pub fn entry_type(&self) -> Result<EntryType, Error>

Returns the entry type.

§Errors

Returns Error::InvalidEntryType if the type byte is not recognized.

Source

pub fn index_first_options_run(&self) -> u8

Returns the index of the first options run.

Source

pub fn index_second_options_run(&self) -> u8

Returns the index of the second options run.

Source

pub fn options_count(&self) -> OptionsCount

Returns the packed options count.

Source

pub fn service_id(&self) -> u16

Returns the service ID.

Source

pub fn instance_id(&self) -> u16

Returns the instance ID.

Source

pub fn major_version(&self) -> u8

Returns the major version.

Source

pub fn ttl(&self) -> u32

Returns the TTL (24-bit value).

Source

pub fn minor_version(&self) -> u32

Minor version (only valid for service entries).

Source

pub fn counter(&self) -> u16

Counter field (only valid for eventgroup entries). Masked to lower 4 bits.

Source

pub fn event_group_id(&self) -> u16

Event group ID (only valid for eventgroup entries).

Source

pub fn to_owned(&self) -> Result<Entry, Error>

Converts this view into an owned Entry.

§Errors

Returns Error::InvalidEntryType if the entry type byte is not recognized.

Trait Implementations§

Source§

impl<'a> Clone for EntryView<'a>

Source§

fn clone(&self) -> EntryView<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for EntryView<'a>

Source§

impl<'a> Debug for EntryView<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Decode<'a> for EntryView<'a>

Source§

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

Per-implementation error; constructible from 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
Source§

fn decode_exact(buf: &'a [u8]) -> Result<Self, Self::Error>

Decode requiring the ENTIRE buffer to be consumed. Use this at a message boundary where the length is already known. Read more
Source§

impl<'a> DecodeIter<'a> for EntryView<'a>

Source§

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>

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

Per-implementation error; constructible from 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.
Source§

fn iter(buf: &'a [u8]) -> DecodeIterator<'a, Self>

Adapter: iterate all elements, yielding Result<Self, Self::Error>. Stops at the first Ok(None) or Err(_).

Auto Trait Implementations§

§

impl<'a> Freeze for EntryView<'a>

§

impl<'a> RefUnwindSafe for EntryView<'a>

§

impl<'a> Send for EntryView<'a>

§

impl<'a> Sync for EntryView<'a>

§

impl<'a> Unpin for EntryView<'a>

§

impl<'a> UnsafeUnpin for EntryView<'a>

§

impl<'a> UnwindSafe for EntryView<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more