pub trait DecodableElement: Sized + Element {
// Required method
fn try_from_buffer_in_place<'a, 'b>(
&'a mut self,
ctx: &DecoderContext<'a>,
buf: &'b [u8],
) -> Result<()>;
// Provided methods
fn try_from_buffer<'b>(
ctx: &DecoderContext<'_>,
buf: &'b [u8],
) -> Result<Self> { ... }
fn try_decode_in_place<'a, 'b>(
&mut self,
ctx: &DecoderContext<'a>,
buf: &'b [u8],
) -> Result<&'b [u8]> { ... }
fn try_decode<'a, 'b>(
ctx: &DecoderContext<'a>,
buf: &'b [u8],
) -> Result<(Self, &'b [u8])> { ... }
fn try_from_reader<R>(ctx: &DecoderContext<'_>, reader: R) -> Result<Self>
where R: Read { ... }
}Expand description
Element that can be decoded from a CDF file
Required Methods§
Sourcefn try_from_buffer_in_place<'a, 'b>(
&'a mut self,
ctx: &DecoderContext<'a>,
buf: &'b [u8],
) -> Result<()>
fn try_from_buffer_in_place<'a, 'b>( &'a mut self, ctx: &DecoderContext<'a>, buf: &'b [u8], ) -> Result<()>
Deserialize the type from a given buffer
As in EncodableElement::to_buffer the implementor of this function can assume the buffer is big
enough to contain all the required bytes.
Provided Methods§
Sourcefn try_from_buffer<'b>(ctx: &DecoderContext<'_>, buf: &'b [u8]) -> Result<Self>
fn try_from_buffer<'b>(ctx: &DecoderContext<'_>, buf: &'b [u8]) -> Result<Self>
Create a new instance of the type from the provided buffer
Sourcefn try_decode_in_place<'a, 'b>(
&mut self,
ctx: &DecoderContext<'a>,
buf: &'b [u8],
) -> Result<&'b [u8]>
fn try_decode_in_place<'a, 'b>( &mut self, ctx: &DecoderContext<'a>, buf: &'b [u8], ) -> Result<&'b [u8]>
Write an element from the buffer, and return the remainder bytes
Assume its inside a validate buffer context
Sourcefn try_decode<'a, 'b>(
ctx: &DecoderContext<'a>,
buf: &'b [u8],
) -> Result<(Self, &'b [u8])>
fn try_decode<'a, 'b>( ctx: &DecoderContext<'a>, buf: &'b [u8], ) -> Result<(Self, &'b [u8])>
Write an element from the buffer, and return the remainder bytes
Assume its inside a validate buffer context
Sourcefn try_from_reader<R>(ctx: &DecoderContext<'_>, reader: R) -> Result<Self>where
R: Read,
fn try_from_reader<R>(ctx: &DecoderContext<'_>, reader: R) -> Result<Self>where
R: Read,
Fetch a new element from a context
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.