pub struct Decoder<'a, D: ResourceDialect> {
pub context: Context,
pub buf: &'a [u8],
/* private fields */
}
Expand description
Decoding state
Fields§
§context: Context
Decoding context.
buf: &'a [u8]
Buffer from which to read data.
Implementations§
source§impl<'a, D: ResourceDialect> Decoder<'a, D>
impl<'a, D: ResourceDialect> Decoder<'a, D>
sourcepub fn decode_into<T: TypeMarker>(
header: &TransactionHeader,
buf: &'a [u8],
handles: &'a mut [<D::Handle as HandleFor<D>>::HandleInfo],
value: &mut T::Owned,
) -> Result<()>
pub fn decode_into<T: TypeMarker>( header: &TransactionHeader, buf: &'a [u8], handles: &'a mut [<D::Handle as HandleFor<D>>::HandleInfo], value: &mut T::Owned, ) -> Result<()>
Decodes a value of FIDL type T
into the Rust type T::Owned
from the
provided data and handle buffers. Assumes the buffers came from inside a
transaction message wrapped by header
.
sourcepub fn decode_with_context<T: TypeMarker>(
context: Context,
buf: &'a [u8],
handles: &'a mut [<D::Handle as HandleFor<D>>::HandleInfo],
value: &mut T::Owned,
) -> Result<()>
pub fn decode_with_context<T: TypeMarker>( context: Context, buf: &'a [u8], handles: &'a mut [<D::Handle as HandleFor<D>>::HandleInfo], value: &mut T::Owned, ) -> Result<()>
Decodes a value of FIDL type T
into the Rust type T::Owned
from the
provided data and handle buffers, using the specified 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 next_out_of_line(&self) -> usize
pub fn next_out_of_line(&self) -> usize
The position of the next out of line block and the end of the current blocks.
sourcepub fn remaining_handles(&self) -> usize
pub fn remaining_handles(&self) -> usize
The number of handles that have not yet been consumed.
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
read an object of type T
at offset
.
sourcepub fn read_num<T: Numeric>(&mut self, offset: usize) -> T
pub fn read_num<T: Numeric>(&mut self, offset: usize) -> T
Decodes a primitive numeric type. The caller must ensure that self.buf
has room for reading T::inline_size
bytes as offset
.
sourcepub unsafe fn out_of_line_offset(&mut self, len: usize) -> Result<usize>
pub unsafe fn out_of_line_offset(&mut self, len: usize) -> Result<usize>
Returns an offset for reading len
out-of-line bytes. Validates that
padding bytes at the end are zero if len
is not a multiple of 8.
§Safety
The caller must ensure that len
is nonzero.
sourcepub fn check_padding(&self, offset: usize, len: usize) -> Result<()>
pub fn check_padding(&self, offset: usize, len: usize) -> Result<()>
Checks that the specified padding bytes are in fact zeroes. Like
Decode::decode
, the caller is responsible for bounds checks.
sourcepub fn check_inline_envelope_padding(
&self,
value_offset: usize,
value_len: usize,
) -> Result<()>
pub fn check_inline_envelope_padding( &self, value_offset: usize, value_len: usize, ) -> Result<()>
Checks the padding of the inline value portion of an envelope. Like
Decode::decode
, the caller is responsible for bounds checks.
Note: check_padding
could be used instead, but doing so leads to long
compilation times which is why this method exists.
sourcepub fn take_next_handle(
&mut self,
expected_object_type: ObjectType,
expected_rights: Rights,
) -> Result<D::Handle>
pub fn take_next_handle( &mut self, expected_object_type: ObjectType, expected_rights: Rights, ) -> Result<D::Handle>
Take the next handle from the handles
list.
sourcepub fn drop_next_handle(&mut self) -> Result<()>
pub fn drop_next_handle(&mut self) -> Result<()>
Drops the next handle in the handle array.