Trait fidl::encoding::Encode

source ·
pub unsafe trait Encode<T: TypeMarker, D: ResourceDialect>: Sized {
    // Required method
    unsafe fn encode(
        self,
        encoder: &mut Encoder<'_, D>,
        offset: usize,
        depth: Depth,
    ) -> Result<()>;
}
Expand description

A Rust type that can be encoded as the FIDL type T.

§Safety

Implementations of encode must write every byte in encoder.buf[offset..offset + T::inline_size(encoder.context)] unless returning an Err value.

Required Methods§

source

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID.

Implementations that encode out-of-line objects must call depth.increment()?.

§Safety

Callers must ensure offset is a multiple of T::inline_align and encoder.buf has room for writing T::inline_size bytes at offset.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<()>

source§

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

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, _depth: Depth, ) -> Result<()>

source§

impl<D: ResourceDialect, T: TypeMarker, X: Encode<T, D>, E: TypeMarker, Y: Encode<E, D>> Encode<ResultType<T, E>, D> for Result<X, Y>

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: ResourceTypeMarker + TypeMarker, const N: usize, D: ResourceDialect> Encode<Vector<T, N>, D> for &mut [<T as TypeMarker>::Owned]
where for<'q> T::Borrowed<'q>: Encode<T, D>,

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: ResourceTypeMarker, const N: usize, D: ResourceDialect> Encode<Array<T, N>, D> for &mut [<T as TypeMarker>::Owned; N]
where for<'q> T::Borrowed<'q>: Encode<T, D>,

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: TypeMarker, E: Encode<T, D>, D: ResourceDialect> Encode<Boxed<T>, D> for Option<E>

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: TypeMarker, E: Encode<T, D>, D: ResourceDialect> Encode<Optional<T>, D> for Option<E>

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: TypeMarker, E: Encode<T, D>, D: ResourceDialect> Encode<OptionalUnion<T>, D> for Option<E>

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: ValueTypeMarker, const N: usize, D: ResourceDialect> Encode<Array<T, N>, D> for &[T::Owned; N]
where for<'q> T::Borrowed<'q>: Encode<T, D>,

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<T: ValueTypeMarker, const N: usize, D: ResourceDialect> Encode<Vector<T, N>, D> for &[<T as TypeMarker>::Owned]
where for<'q> T::Borrowed<'q>: Encode<T, D>,

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

source§

impl<const N: usize, D: ResourceDialect> Encode<BoundedString<N>, D> for &str

source§

unsafe fn encode( self, encoder: &mut Encoder<'_, D>, offset: usize, depth: Depth, ) -> Result<()>

Implementors§