pub struct Encoder<'a> { /* private fields */ }
Expand description
Encoding state
Implementations§
source§impl<'a> Encoder<'a>
impl<'a> Encoder<'a>
sourcepub fn encode<T: TypeMarker>(
buf: &'a mut Vec<u8>,
handles: &'a mut Vec<HandleDisposition<'static>>,
x: impl Encode<T>
) -> Result<()>
pub fn encode<T: TypeMarker>( buf: &'a mut Vec<u8>, handles: &'a mut Vec<HandleDisposition<'static>>, x: impl Encode<T> ) -> 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<HandleDisposition<'static>>,
x: impl Encode<T>
) -> Result<()>
pub fn encode_with_context<T: TypeMarker>( context: Context, buf: &'a mut Vec<u8>, handles: &'a mut Vec<HandleDisposition<'static>>, x: impl Encode<T> ) -> 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 mut_buffer(&mut self) -> &mut [u8] ⓘ
pub fn mut_buffer(&mut self) -> &mut [u8] ⓘ
Returns the buffer we are encoding into.
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 out_of_line_offset(&mut self, len: usize) -> usize
pub fn out_of_line_offset(&mut self, len: usize) -> usize
Returns an offset for writing len
out-of-line bytes (must be nonzero).
Takes care of zeroing the padding bytes if len
is not a multiple of 8.
The caller must also call depth.increment()?
.
sourcepub fn append_out_of_line_bytes(&mut self, bytes: &[u8])
pub fn append_out_of_line_bytes(&mut self, bytes: &[u8])
Append bytes to the very end (out-of-line) of the buffer.