pub struct SdBody<'a> { /* private fields */ }Expand description
Lazy zero-copy view over an SD payload body.
SdBody::decode performs only the O(1) flag decode and section slicing
(with the accompanying length / entries_size-multiple checks); it does NOT
walk the entries validating their type bytes, nor the options validating
their type / length / transport-protocol bytes. That per-element validation
is the job of the lazy DecodeIter adapters returned by SdBody::entries
/ SdBody::options, or of the L2 validation pass (SdHeaderView::parse).
Contrast with SdHeaderView, which validates everything upfront so its
iterators are infallible.
Implementations§
Source§impl<'a> SdBody<'a>
impl<'a> SdBody<'a>
Sourcepub fn entries(&self) -> DecodeIterator<'a, EntryView<'a>> ⓘ
pub fn entries(&self) -> DecodeIterator<'a, EntryView<'a>> ⓘ
Returns a lazy iterator over the SD entries.
Each item is a Result<EntryView, Error>; a malformed/truncated entry
surfaces as an Err. The entry-type byte is not validated here — call
EntryView::entry_type / EntryView::to_owned to validate it.
Sourcepub fn options(&self) -> DecodeIterator<'a, OptionView<'a>> ⓘ
pub fn options(&self) -> DecodeIterator<'a, OptionView<'a>> ⓘ
Returns a lazy iterator over the SD options.
Each item is a Result<OptionView, Error>; a malformed/truncated option
surfaces as an Err. Option type / length / transport-protocol bytes
are not validated here — validate them via the OptionView accessors.
Trait Implementations§
impl<'a> Copy for SdBody<'a>
Source§impl<'a> Decode<'a> for SdBody<'a>
impl<'a> Decode<'a> for SdBody<'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 and slice an SD payload body from the front of buf.
Performs only the flag decode and the section slicing / length checks
(buffer minimum, entries_size multiple-of-16, and section bounds). It
deliberately does NOT validate entry-type bytes or option contents —
see the type-level docs.
§Errors
Returns Incomplete if the buffer
is too short for the declared sections, or
IncorrectEntriesSize if
entries_size is not a multiple of ENTRY_SIZE (16).
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