pub struct Encoder<'a, D: ResourceDialect> {
pub context: Context,
pub buf: &'a mut Vec<u8>,
/* private fields */
}
Expand description
Encoding state
Fields§
§context: Context
Encoding context.
buf: &'a mut Vec<u8>
Buffer to write output data into.
Implementations§
Source§impl<'a, D: ResourceDialect> Encoder<'a, D>
impl<'a, D: ResourceDialect> Encoder<'a, D>
Sourcepub fn encode<T: TypeMarker>(
buf: &'a mut Vec<u8>,
handles: &'a mut Vec<<D::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition>,
x: impl Encode<T, D>,
) -> Result<()>
pub fn encode<T: TypeMarker>( buf: &'a mut Vec<u8>, handles: &'a mut Vec<<D::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition>, x: impl Encode<T, D>, ) -> Result<()>
FIDL-encodes x
into the provided data and handle buffers.
Sourcepub fn encode_with_context<T: TypeMarker>(
context: Context,
buf: &'a mut Vec<u8>,
handles: &'a mut Vec<<D::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition>,
x: impl Encode<T, D>,
) -> Result<()>
pub fn encode_with_context<T: TypeMarker>( context: Context, buf: &'a mut Vec<u8>, handles: &'a mut Vec<<D::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition>, x: impl Encode<T, D>, ) -> Result<()>
FIDL-encodes x
into the provided data and handle buffers, using the
specified encoding context.
WARNING: Do not call this directly unless you know what you’re doing.
FIDL uses Context
to coordinate soft migrations, so improper uses of
this function could result in ABI breakage.
Sourcepub fn debug_check_bounds<T: TypeMarker>(&self, offset: usize)
pub fn debug_check_bounds<T: TypeMarker>(&self, offset: usize)
In debug mode only, asserts that there is enough room in the buffer to
write an object of type T
at offset
.
Sourcepub unsafe fn write_num<T: Numeric>(&mut self, num: T, offset: usize)
pub unsafe fn write_num<T: Numeric>(&mut self, num: T, offset: usize)
Encodes a primitive numeric type.
§Safety
The caller must ensure that self.buf
has room for writing
T::inline_size
bytes as offset
.
Sourcepub fn push_next_handle(
&mut self,
handle: <D::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition,
)
pub fn push_next_handle( &mut self, handle: <D::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition, )
Writes the given handle to the handles list.
Sourcepub unsafe fn out_of_line_offset(&mut self, len: usize) -> usize
pub unsafe fn out_of_line_offset(&mut self, len: usize) -> usize
Returns an offset for writing len
out-of-line bytes. Zeroes padding
bytes at the end if len
is not a multiple of 8.
§Safety
The caller must ensure that len
is nonzero.