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§
Sourceunsafe fn encode(
self,
encoder: &mut Encoder<'_, D>,
offset: usize,
depth: Depth,
) -> Result<()>
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.