Skip to main content

MapEntry

Struct MapEntry 

Source
pub struct MapEntry<'a, 'r, K, V, R: BorrowedReader + 'r> { /* private fields */ }
Expand description

One key+value pair inside a MapWalker.

The cursor is positioned at the start of the key. The caller must first handle the key (decode_key or skip_key) and then the value (decode_value, skip_value, or walk_value). decode_pair and skip_pair shortcut both at once.

Calling methods out of order returns Error::Deserialize in all builds (not only debug builds), without advancing the reader when the check fails before I/O.

Implementations§

Source§

impl<'a, 'r, K, V, R: BorrowedReader + 'r> MapEntry<'a, 'r, K, V, R>

Source

pub fn decode_key(&mut self) -> Result<K, Error>

Decode the key. The cursor advances to the value.

Source

pub fn skip_key(&mut self) -> Result<(), Error>
where K: SkipRevisioned,

Skip the key. The cursor advances to the value.

Source

pub fn decode_value(self) -> Result<V, Error>

Decode the value (key must already be consumed).

Source

pub fn skip_value(self) -> Result<(), Error>
where V: SkipRevisioned,

Skip the value (key must already be consumed).

Source

pub fn walk_value(self) -> Result<V::Walker<'a, R>, Error>
where V: WalkRevisioned,

Walk into the value. The parent map walker is borrowed for the returned walker’s lifetime.

Source

pub fn decode_pair(self) -> Result<(K, V), Error>

Decode key and value together, advancing past the entry.

Source

pub fn skip_pair(self) -> Result<(), Error>

Skip key and value together, advancing past the entry.

Source§

impl<'a, 'r, K, V, R> MapEntry<'a, 'r, K, V, R>
where R: BorrowedReader + 'r,

Source

pub fn with_key_bytes<F, U>(&mut self, f: F) -> Result<U, Error>
where K: LengthPrefixedBytes, F: FnOnce(&[u8]) -> U,

Inspect the entry’s key as raw wire bytes without allocating.

Available when the key type’s wire format is usize len || raw bytes (LengthPrefixedBytes) and the reader is slice-backed (BorrowedReader). The cursor advances past the key once f returns; the caller must then handle the value (decode_value / skip_value / walk_value).

Cheaper sibling of decode_key for the common case “compare key bytes against a needle and decide what to do with the value”.

Source

pub fn with_value_bytes<F, U>(self, f: F) -> Result<U, Error>
where V: LengthPrefixedBytes, F: FnOnce(&[u8]) -> U,

Inspect the entry’s value as raw wire bytes without allocating (key must already be consumed).

Available when the value type’s wire format is usize len || raw bytes (LengthPrefixedBytes) and the reader is slice-backed (BorrowedReader). Consumes the entry; the entry’s remaining counter is decremented.

Cheaper sibling of decode_value for the “filter map by value bytes” pattern.

Auto Trait Implementations§

§

impl<'a, 'r, K, V, R> Freeze for MapEntry<'a, 'r, K, V, R>

§

impl<'a, 'r, K, V, R> RefUnwindSafe for MapEntry<'a, 'r, K, V, R>
where R: RefUnwindSafe,

§

impl<'a, 'r, K, V, R> Send for MapEntry<'a, 'r, K, V, R>
where R: Send,

§

impl<'a, 'r, K, V, R> Sync for MapEntry<'a, 'r, K, V, R>
where R: Sync,

§

impl<'a, 'r, K, V, R> Unpin for MapEntry<'a, 'r, K, V, R>

§

impl<'a, 'r, K, V, R> UnsafeUnpin for MapEntry<'a, 'r, K, V, R>

§

impl<'a, 'r, K, V, R> !UnwindSafe for MapEntry<'a, 'r, K, V, R>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.