pub struct Proxied<E, Tag = ()>(/* private fields */);Expand description
Proxied is a special encoder which translates the encoded type into its “proxy” type first,
simplifying the encoding logic. It provides value-encoding implementations for types that
implement the proxied conversions defined in Proxiable and DistinguishedProxiable, which can
then be delegated (such as with delegate_value_encoding!) to another encoding to be used as
field types in messages.
Proxied itself cannot be used to encode message fields because its
trait support means that it cannot ever implement Encoder, Decoder etc. for its supported,
un-wrapped types; only when they are nested in Option<T>, or appear in a oneof, or in some
other container.
Trait Implementations§
Source§impl<'a, T, E, Tag> DistinguishedValueBorrowDecoder<'a, Proxied<E, Tag>, T> for ()where
T: DistinguishedProxiable<Tag> + Eq,
(): ForOverwrite<E, T::Proxy> + DistinguishedValueBorrowDecoder<'a, E, T::Proxy>,
impl<'a, T, E, Tag> DistinguishedValueBorrowDecoder<'a, Proxied<E, Tag>, T> for ()where
T: DistinguishedProxiable<Tag> + Eq,
(): ForOverwrite<E, T::Proxy> + DistinguishedValueBorrowDecoder<'a, E, T::Proxy>,
Source§const CHECKS_EMPTY: bool
const CHECKS_EMPTY: bool
Indicates whether the
ALLOW_EMPTY argument in borrow_decode_value_distinguished has any
effect. Some decoder implementations can more cheaply determine whether they were empty
during decoding, and will return NotCanonical if ALLOW_EMPTY was false; for these
implementations, CHECKS_EMPTY should be set to true. When CHECKS_EMPTY is false, the
caller must invoke EmptyState::is_empty after the call if empty states are non-canonical.Source§fn borrow_decode_value_distinguished<const ALLOW_EMPTY: bool>(
value: &mut T,
buf: Capped<'_, &'a [u8]>,
ctx: RestrictedDecodeContext,
) -> Result<Canonicity, DecodeError>
fn borrow_decode_value_distinguished<const ALLOW_EMPTY: bool>( value: &mut T, buf: Capped<'_, &'a [u8]>, ctx: RestrictedDecodeContext, ) -> Result<Canonicity, DecodeError>
Decodes a field assuming the encoder’s wire type directly from the buffer, also performing
any additional validation required to guarantee that the value would be re-encoded into the
exact same bytes.
Source§impl<T, E, Tag> DistinguishedValueDecoder<Proxied<E, Tag>, T> for ()where
T: DistinguishedProxiable<Tag> + Eq,
(): ForOverwrite<E, T::Proxy> + DistinguishedValueDecoder<E, T::Proxy>,
impl<T, E, Tag> DistinguishedValueDecoder<Proxied<E, Tag>, T> for ()where
T: DistinguishedProxiable<Tag> + Eq,
(): ForOverwrite<E, T::Proxy> + DistinguishedValueDecoder<E, T::Proxy>,
Source§const CHECKS_EMPTY: bool
const CHECKS_EMPTY: bool
Indicates whether the
ALLOW_EMPTY argument in decode_value_distinguished has any effect.
Some decoder implementations can more cheaply determine whether they were empty during
decoding, and will return NotCanonical if ALLOW_EMPTY was false; for these
implementations, CHECKS_EMPTY should be set to true. When CHECKS_EMPTY is false, the
caller must invoke EmptyState::is_empty after the call if empty states are non-canonical.Source§fn decode_value_distinguished<const ALLOW_EMPTY: bool>(
value: &mut T,
buf: Capped<'_, impl Buf + ?Sized>,
ctx: RestrictedDecodeContext,
) -> Result<Canonicity, DecodeError>
fn decode_value_distinguished<const ALLOW_EMPTY: bool>( value: &mut T, buf: Capped<'_, impl Buf + ?Sized>, ctx: RestrictedDecodeContext, ) -> Result<Canonicity, DecodeError>
Decodes a field assuming the encoder’s wire type directly from the buffer, also performing
any additional validation required to guarantee that the value would be re-encoded into the
exact same bytes.
Source§impl<'a, T, E, Tag> ValueBorrowDecoder<'a, Proxied<E, Tag>, T> for ()
impl<'a, T, E, Tag> ValueBorrowDecoder<'a, Proxied<E, Tag>, T> for ()
Source§fn borrow_decode_value(
value: &mut T,
buf: Capped<'_, &'a [u8]>,
ctx: DecodeContext,
) -> Result<(), DecodeError>
fn borrow_decode_value( value: &mut T, buf: Capped<'_, &'a [u8]>, ctx: DecodeContext, ) -> Result<(), DecodeError>
Decodes a field assuming the encoder’s wire type directly from the buffer.
Source§impl<T, E, Tag> ValueDecoder<Proxied<E, Tag>, T> for ()
impl<T, E, Tag> ValueDecoder<Proxied<E, Tag>, T> for ()
Source§fn decode_value<B: Buf + ?Sized>(
value: &mut T,
buf: Capped<'_, B>,
ctx: DecodeContext,
) -> Result<(), DecodeError>
fn decode_value<B: Buf + ?Sized>( value: &mut T, buf: Capped<'_, B>, ctx: DecodeContext, ) -> Result<(), DecodeError>
Decodes a field assuming the encoder’s wire type directly from the buffer.
Source§impl<T, E, Tag> ValueEncoder<Proxied<E, Tag>, T> for ()
impl<T, E, Tag> ValueEncoder<Proxied<E, Tag>, T> for ()
Source§fn encode_value<B: BufMut + ?Sized>(value: &T, buf: &mut B)
fn encode_value<B: BufMut + ?Sized>(value: &T, buf: &mut B)
Encodes the given value unconditionally. This is guaranteed to emit data to the buffer.
Source§fn prepend_value<B: ReverseBuf + ?Sized>(value: &T, buf: &mut B)
fn prepend_value<B: ReverseBuf + ?Sized>(value: &T, buf: &mut B)
Prepends the given value unconditionally. This is guaranteed to emit data to the buffer.
Source§fn value_encoded_len(value: &T) -> usize
fn value_encoded_len(value: &T) -> usize
Returns the number of bytes the given value would be encoded as.
Source§fn many_values_encoded_len<I>(values: I) -> usize
fn many_values_encoded_len<I>(values: I) -> usize
Returns the number of total bytes to encode all the values in the given container.
Auto Trait Implementations§
impl<E, Tag> Freeze for Proxied<E, Tag>
impl<E, Tag> RefUnwindSafe for Proxied<E, Tag>where
E: RefUnwindSafe,
Tag: RefUnwindSafe,
impl<E, Tag> Send for Proxied<E, Tag>
impl<E, Tag> Sync for Proxied<E, Tag>
impl<E, Tag> Unpin for Proxied<E, Tag>
impl<E, Tag> UnsafeUnpin for Proxied<E, Tag>where
E: UnsafeUnpin,
Tag: UnsafeUnpin,
impl<E, Tag> UnwindSafe for Proxied<E, Tag>where
E: UnwindSafe,
Tag: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more