Trait fidl::encoding::Decode

source ·
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§

source

fn new_empty() -> Self

Creates a valid instance of Self. The specific value does not matter, since it will be overwritten by decode.

source

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.

Implementations on Foreign Types§

source§

impl<D: ResourceDialect> Decode<bool, D> for bool

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<f32, D> for f32

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<f64, D> for f64

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<i8, D> for i8

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<i16, D> for i16

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<i32, D> for i32

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<i64, D> for i64

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<u8, D> for u8

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<u16, D> for u16

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<u32, D> for u32

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<u64, D> for u64

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<EmptyPayload, D> for ()

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, _decoder: &mut Decoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect> Decode<EmptyStruct, D> for ()

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect, T: TypeMarker, E: TypeMarker> Decode<ResultType<T, E>, D> for Result<T::Owned, E::Owned>
where T::Owned: Decode<T, D>, E::Owned: Decode<E, D>,

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: TypeMarker, D: ResourceDialect> Decode<Boxed<T>, D> for Option<Box<T::Owned>>
where T::Owned: Decode<T, D>,

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: TypeMarker, D: ResourceDialect> Decode<Optional<T>, D> for Option<T::Owned>
where T::Owned: Decode<T, D>,

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: TypeMarker, D: ResourceDialect> Decode<OptionalUnion<T>, D> for Option<Box<T::Owned>>
where T::Owned: Decode<T, D>,

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: TypeMarker, const N: usize, D: ResourceDialect> Decode<Array<T, N>, D> for [T::Owned; N]
where T::Owned: Decode<T, D>,

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: TypeMarker, const N: usize, D: ResourceDialect> Decode<Vector<T, N>, D> for Vec<T::Owned>
where T::Owned: Decode<T, D>,

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<const N: usize, D: ResourceDialect> Decode<BoundedString<N>, D> for String

source§

fn new_empty() -> Self

source§

unsafe fn decode( &mut self, decoder: &mut Decoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

Implementors§