pub struct NodePath<'a> { /* private fields */ }Expand description
A borrowed node path: little-endian u16 components over the envelope’s
own buffer.
Holding the raw bytes rather than a &[u16] avoids both an alignment
requirement the envelope cannot guarantee and a copy the boundary does not
need.
Implementations§
Source§impl<'a> NodePath<'a>
impl<'a> NodePath<'a>
Sourcepub const fn from_le_bytes(bytes: &'a [u8]) -> Self
pub const fn from_le_bytes(bytes: &'a [u8]) -> Self
Wrap the little-endian component bytes of a path.
bytes.len() must be even; the decoder only ever produces such slices.
An odd length drops the trailing half-component here, at construction,
rather than at each read: a path whose byte count disagreed with its
component count would encode a length prefix the decoder then uses to
take fewer bytes than were written, shifting every field after it.
Sourcepub fn iter(self) -> impl Iterator<Item = u16> + 'a
pub fn iter(self) -> impl Iterator<Item = u16> + 'a
Iterate the components from the root downwards.
as_chunks yields fixed-size pairs, so decoding needs no fallible step
and a trailing odd byte is simply not a component.
Sourcepub const fn as_le_bytes(self) -> &'a [u8] ⓘ
pub const fn as_le_bytes(self) -> &'a [u8] ⓘ
The underlying little-endian bytes.
Sourcepub fn starts_with(self, other: NodePath<'_>) -> bool
pub fn starts_with(self, other: NodePath<'_>) -> bool
Whether self is other or a node beneath it.