pub trait Decodable<Dec, Err>: Versioned<Err>{
// Provided methods
fn decode(decoder: &mut Dec) -> Result<Self::Output, Err> { ... }
fn decode_with_version(
decoder: &mut Dec,
version: u32,
) -> Result<Self::Output, Err> { ... }
unsafe fn decode_body(decoder: &mut Dec) -> Result<Self::Output, Err> { ... }
}Expand description
This trait is used to mark a versioned type as decodable. Usually this is provided by the versioned! macro.
Provided Methods§
Sourcefn decode(decoder: &mut Dec) -> Result<Self::Output, Err>
fn decode(decoder: &mut Dec) -> Result<Self::Output, Err>
Decodes versioned data and validates the version. Will consume the version from the reader.
§Errors
- Returns an error if the version is invalid.
- Returns an error if the data is invalid.
Sourcefn decode_with_version(
decoder: &mut Dec,
version: u32,
) -> Result<Self::Output, Err>
fn decode_with_version( decoder: &mut Dec, version: u32, ) -> Result<Self::Output, Err>
Decodes the data with a provided version tag. Is helpful for use in combination with Upgrade.
§Errors
- Returns an error if the version is invalid.
- Returns an error if the data is invalid.
Sourceunsafe fn decode_body(decoder: &mut Dec) -> Result<Self::Output, Err>
unsafe fn decode_body(decoder: &mut Dec) -> Result<Self::Output, Err>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.