pub trait Decode: Sized {
// Required method
fn decode(bytes: &mut Cursor<&[u8]>) -> Result<Self, CodecError>;
// Provided method
fn get_decoded(bytes: &[u8]) -> Result<Self, CodecError> { ... }
}
Expand description
Describes how to decode an object from a byte sequence.
Required Methods§
sourcefn decode(bytes: &mut Cursor<&[u8]>) -> Result<Self, CodecError>
fn decode(bytes: &mut Cursor<&[u8]>) -> Result<Self, CodecError>
Read and decode an encoded object from bytes
. On success, the decoded value is returned
and bytes
is advanced by the encoded size of the value. On failure, an error is returned
and no further attempt to read from bytes
should be made.
Provided Methods§
sourcefn get_decoded(bytes: &[u8]) -> Result<Self, CodecError>
fn get_decoded(bytes: &[u8]) -> Result<Self, CodecError>
Convenience method to get a decoded value. Returns an error if Self::decode
fails, or if
there are any bytes left in bytes
after decoding a value.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
Implementors§
impl Decode for PingPongMessage
impl Decode for Field64
impl Decode for Field128
impl Decode for Field255
impl Decode for FieldPrio2
impl Decode for AggregationParam
Available on crate feature
test-util
only.impl Decode for PrepareState
Available on crate feature
test-util
only.impl Decode for Poplar1AggregationParam
Available on crate features
crypto-dependencies
and experimental
only.impl<F> Decode for Poplar1IdpfValue<F>where
F: Decode,
Available on crate features
crypto-dependencies
and experimental
only.