Unverified Commit 1dc22f6f authored by thiolliere's avatar thiolliere Committed by GitHub
Browse files

Improve Decode trait, without improving implementations (#243)

Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: David's avatarDavid <dvdplm@gmail.com>
parent adcde460
Pipeline #121406 canceled with stages
in 5 minutes and 21 seconds
......@@ -307,7 +307,25 @@ pub trait Decode: Sized {
const TYPE_INFO: TypeInfo = TypeInfo::Unknown;
/// Attempt to deserialise the value from input.
fn decode<I: Input>(value: &mut I) -> Result<Self, Error>;
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>;
/// Attempt to skip the encoded value from input.
/// The default implementation of this function is just calling [`Decode::decode`].
/// When possible, an implementation should provided a specialized implementation.
fn skip<I: Input>(input: &mut I) -> Result<(), Error> {
Self::decode(input).map(|_| ())
/// Returns the fixed encoded size of the type.
/// If it returns `Some(size)` then all possible values of this
/// type have the given size (in bytes) when encoded.
/// NOTE: A type with a fixed encoded size may return `None`.
fn encoded_fixed_size() -> Option<usize> {
/// Trait that allows zero-copy read/write of value-references to/from slices in LE format.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment