Trait pod::code::Decode
[−]
[src]
pub trait Decode: Sized { type Options: Default; fn decode<R: Read>(r: &mut R) -> Result<Self> { ... } fn decode_options<R: Read>(r: &mut R, _options: Self::Options) -> Result<Self> { ... } fn decode_slice(data: &[u8]) -> Result<Self> { ... } fn decode_slice_options(data: &[u8], options: Self::Options) -> Result<Self> { ... } fn validate(&self) -> Result<()> { ... } }
Decodes data from a Read
into a new value.
See Encode
for more details.
Associated Types
type Options: Default
Options will affect how the value is decoded, and may be used to provide any data that is normally lost during encoding.
Provided Methods
fn decode<R: Read>(r: &mut R) -> Result<Self>
Decodes from the Read
with default options
fn decode_options<R: Read>(r: &mut R, _options: Self::Options) -> Result<Self>
Decodes from the Read
with the provided options
fn decode_slice(data: &[u8]) -> Result<Self>
Decodes from a byte slice
fn decode_slice_options(data: &[u8], options: Self::Options) -> Result<Self>
Decodes from a byte slice with the provided options
fn validate(&self) -> Result<()>
Implement to assert that the decoded contents are valid
Warning
This takes &self
, meaning the object is still created before validation occurs.
Therefore any Drop
implementations must not assume that the object is valid.