fidl::encoding

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

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