pub trait Decode<T: TypeMarker, D>: 'static + Sized {
// Required methods
fn new_empty() -> Self;
unsafe fn decode(
&mut self,
decoder: &mut Decoder<'_, D>,
offset: usize,
depth: Depth,
) -> Result<()>
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<()>where
D: ResourceDialect,
unsafe fn decode(
&mut self,
decoder: &mut Decoder<'_, D>,
offset: usize,
depth: Depth,
) -> Result<()>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
.
Object Safety§
This trait is not object safe.