fidl::encoding

Trait 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.

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.

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§