Skip to main content

Proxied

Struct Proxied 

Source
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 ()

Source§

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>

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 ()

Source§

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>

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 ()
where T: Proxiable<Tag>, (): ForOverwrite<E, T::Proxy> + ValueBorrowDecoder<'a, E, T::Proxy>,

Source§

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 ()
where T: Proxiable<Tag>, (): ForOverwrite<E, T::Proxy> + ValueDecoder<E, T::Proxy>,

Source§

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 ()
where T: Proxiable<Tag>, (): ForOverwrite<E, T::Proxy> + ValueEncoder<E, T::Proxy>,

Source§

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)

Prepends the given value unconditionally. This is guaranteed to emit data to the buffer.
Source§

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
where I: ExactSizeIterator, I::Item: Deref<Target = T>,

Returns the number of total bytes to encode all the values in the given container.
Source§

impl<T, E, Tag> Wiretyped<Proxied<E, Tag>, T> for ()
where T: Proxiable<Tag>, (): Wiretyped<E, T::Proxy> + ForOverwrite<E, T::Proxy>,

Auto Trait Implementations§

§

impl<E, Tag> Freeze for Proxied<E, Tag>
where E: Freeze, Tag: Freeze,

§

impl<E, Tag> RefUnwindSafe for Proxied<E, Tag>

§

impl<E, Tag> Send for Proxied<E, Tag>
where E: Send, Tag: Send,

§

impl<E, Tag> Sync for Proxied<E, Tag>
where E: Sync, Tag: Sync,

§

impl<E, Tag> Unpin for Proxied<E, Tag>
where E: Unpin, Tag: Unpin,

§

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> 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.