Trait prio::codec::ParameterizedEncode

source ·
pub trait ParameterizedEncode<P> {
    // Required method
    fn encode_with_param(
        &self,
        encoding_parameter: &P,
        bytes: &mut Vec<u8>
    ) -> Result<(), CodecError>;

    // Provided methods
    fn get_encoded_with_param(
        &self,
        encoding_parameter: &P
    ) -> Result<Vec<u8>, CodecError> { ... }
    fn encoded_len_with_param(&self, _encoding_parameter: &P) -> Option<usize> { ... }
}
Expand description

Describes how to encode objects into a byte sequence.

Required Methods§

source

fn encode_with_param( &self, encoding_parameter: &P, bytes: &mut Vec<u8> ) -> Result<(), CodecError>

Append the encoded form of this object to the end of bytes, growing the vector as needed. encoding_parameter provides details of the wire encoding, used to control how the value is encoded.

Provided Methods§

source

fn get_encoded_with_param( &self, encoding_parameter: &P ) -> Result<Vec<u8>, CodecError>

Convenience method to encode a value into a new Vec<u8>.

source

fn encoded_len_with_param(&self, _encoding_parameter: &P) -> Option<usize>

Returns an optional hint indicating how many bytes will be required to encode this value, or None by default.

Implementors§

source§

impl<E: Encode + ?Sized, T> ParameterizedEncode<T> for E

Provide a blanket implementation so that any Encode can be used as a ParameterizedEncode<T> for any T.