pub struct CodecValueDecoder<C> { /* private fields */ }Expand description
Decodes one encoded unit slice into one owned value by using a Codec.
CodecValueDecoder is the default bridge from the low-level unchecked
Codec contract to the convenience-layer ValueDecoder contract. The
supplied input slice must contain exactly one encoded value. Successfully
decoded prefixes followed by extra units are reported as trailing input.
§Type Parameters
C: Low-level codec used to decode one value.
Implementations§
Trait Implementations§
Source§impl<C: Clone> Clone for CodecValueDecoder<C>
impl<C: Clone> Clone for CodecValueDecoder<C>
Source§fn clone(&self) -> CodecValueDecoder<C>
fn clone(&self) -> CodecValueDecoder<C>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<C: Copy> Copy for CodecValueDecoder<C>
Source§impl<C: Debug> Debug for CodecValueDecoder<C>
impl<C: Debug> Debug for CodecValueDecoder<C>
Source§impl<C: Default> Default for CodecValueDecoder<C>
impl<C: Default> Default for CodecValueDecoder<C>
Source§fn default() -> CodecValueDecoder<C>
fn default() -> CodecValueDecoder<C>
impl<C: Eq> Eq for CodecValueDecoder<C>
Source§impl<C: Hash> Hash for CodecValueDecoder<C>
impl<C: Hash> Hash for CodecValueDecoder<C>
Source§impl<C: PartialEq> PartialEq for CodecValueDecoder<C>
impl<C: PartialEq> PartialEq for CodecValueDecoder<C>
Source§fn eq(&self, other: &CodecValueDecoder<C>) -> bool
fn eq(&self, other: &CodecValueDecoder<C>) -> bool
self and other values to be equal, and is used by ==.impl<C> StructuralPartialEq for CodecValueDecoder<C>
Source§impl<C> ValueDecoder<[<C as Codec>::Unit]> for CodecValueDecoder<C>where
C: Codec,
impl<C> ValueDecoder<[<C as Codec>::Unit]> for CodecValueDecoder<C>where
C: Codec,
Source§fn decode(&self, input: &[C::Unit]) -> Result<Self::Output, Self::Error>
fn decode(&self, input: &[C::Unit]) -> Result<Self::Output, Self::Error>
Decodes exactly one encoded value from input.
§Parameters
input: Encoded units for exactly one value.
§Returns
Returns the decoded value.
§Errors
Returns CodecDecodeError::Incomplete when fewer than
Codec::min_units_per_value units are available. Returns
CodecDecodeError::Decode when the wrapped codec rejects the input.
Returns CodecDecodeError::TrailingInput when a value is decoded but
extra input remains.
§Panics
Panics when the wrapped codec reports a consumed unit count larger than the input slice length.