pub struct LazyRepeatedView<'a, V> { /* private fields */ }Expand description
A deferred view of a repeated message field on a lazy view.
Holds the wire byte-slice of each element (cheap pointers) and decodes a
fresh element view on access (get) or iteration
(iter), instead of eagerly decoding every element into a
Vec like RepeatedView.
Element bytes are not validated when the enclosing view is decoded; a
malformed element surfaces as a DecodeError from get/iter. Unlike
RepeatedView, this type is not slice-backed: there is no Deref or
indexing, use get/iter/len. Budgets and re-encoding behave as on
LazyMessageFieldView.
Implementations§
Source§impl<'a, V> LazyRepeatedView<'a, V>
impl<'a, V> LazyRepeatedView<'a, V>
Source§impl<'a, V: LazyMessageView<'a>> LazyRepeatedView<'a, V>
impl<'a, V: LazyMessageView<'a>> LazyRepeatedView<'a, V>
Sourcepub fn get(&self, index: usize) -> Option<Result<V, DecodeError>>
pub fn get(&self, index: usize) -> Option<Result<V, DecodeError>>
Decode the element at index, or None if out of range.
Re-decodes on every call (no cache) — bind the result when reading
multiple fields, and avoid calling it inside a tight loop over the
same index. Note the shape difference from
LazyMessageFieldView::get, which returns Result<Option<V>, _>.
Sourcepub fn try_get(&self, index: usize) -> Result<Option<V>, DecodeError>
pub fn try_get(&self, index: usize) -> Result<Option<V>, DecodeError>
Like get with the layers flipped to match
LazyMessageFieldView::get’s Result<Option<_>, _> shape:
out-of-range yields Ok(None).
§Errors
Same as get.
Sourcepub fn iter(&self) -> LazyRepeatedIter<'_, 'a, V> ⓘ
pub fn iter(&self) -> LazyRepeatedIter<'_, 'a, V> ⓘ
Iterate the elements, decoding each on the fly.
Yields Result<V, DecodeError> — element bytes are validated here,
not when the enclosing view was decoded. Each pass over the iterator
re-decodes the elements (no cache).