pub struct UnknownFields { /* private fields */ }Expand description
A collection of unknown fields encountered during decoding.
When a message is decoded with a schema that doesn’t include all fields present on the wire, the unknown fields are stored here so they can be re-encoded without data loss.
Implementations§
Source§impl UnknownFields
impl UnknownFields
Sourcepub fn push(&mut self, field: UnknownField)
pub fn push(&mut self, field: UnknownField)
Appends an unknown field.
Sourcepub fn iter(&self) -> Iter<'_, UnknownField>
pub fn iter(&self) -> Iter<'_, UnknownField>
Returns an iterator over the recorded unknown fields.
Sourcepub fn retain(&mut self, f: impl FnMut(&UnknownField) -> bool)
pub fn retain(&mut self, f: impl FnMut(&UnknownField) -> bool)
Retain only the fields for which the predicate returns true.
Used by ExtensionSet::set_extension
and clear_extension to remove
prior occurrences at a given field number.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Compute the encoded size of all unknown fields.
Sourcepub fn write_to(&self, buf: &mut impl BufMut)
pub fn write_to(&self, buf: &mut impl BufMut)
Re-encode all unknown fields to buf in their original wire format.
Sourcepub fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>
pub fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>
Decode a concatenation of wire-format fields into UnknownFields.
Reads tag/data pairs until data is exhausted. Each field is decoded
via decode_unknown_field with
the full RECURSION_LIMIT budget.
Used by GroupCodec to turn a
message’s encoded bytes back into the inner-field representation that
UnknownFieldData::Group wraps.
§Errors
Returns DecodeError if data contains a
malformed tag, truncated field, or exceeds the recursion limit.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for UnknownFields
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for UnknownFields
arbitrary only.Source§fn arbitrary(_u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(_u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Clone for UnknownFields
impl Clone for UnknownFields
Source§fn clone(&self) -> UnknownFields
fn clone(&self) -> UnknownFields
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more