pub trait Decode<T, D>: Sized + 'staticwhere
T: TypeMarker,{
// Required methods
fn new_empty() -> Self;
unsafe fn decode(
&mut self,
decoder: &mut Decoder<'_, D>,
offset: usize,
depth: Depth,
) -> Result<(), Error>
where D: ResourceDialect;
}
Expand description
A Rust type that can be decoded from the FIDL type T
.
Required Methods§
Sourcefn new_empty() -> Self
fn new_empty() -> Self
Creates a valid instance of Self
. The specific value does not matter,
since it will be overwritten by decode
.
Sourceunsafe fn decode(
&mut self,
decoder: &mut Decoder<'_, D>,
offset: usize,
depth: Depth,
) -> Result<(), Error>where
D: ResourceDialect,
unsafe fn decode(
&mut self,
decoder: &mut Decoder<'_, D>,
offset: usize,
depth: Depth,
) -> Result<(), Error>where
D: ResourceDialect,
Decodes an object of type T
from the decoder’s buffers into self
.
Implementations must validate every byte in
decoder.buf[offset..offset + T::inline_size(decoder.context)]
unless
returning an Err
value. Implementations that decode out-of-line
objects must call depth.increment()?
.
§Safety
Callers must ensure offset
is a multiple of T::inline_align
and
decoder.buf
has room for reading T::inline_size
bytes at offset
.
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.