Struct Decoder
pub struct Decoder<'a, D>where
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§
§impl<'a, D> Decoder<'a, D>where
D: ResourceDialect,
impl<'a, D> Decoder<'a, D>where
D: ResourceDialect,
pub fn decode_into<T>(
header: &TransactionHeader,
buf: &'a [u8],
handles: &'a mut [<<D as ResourceDialect>::Handle as HandleFor<D>>::HandleInfo],
value: &mut <T as TypeMarker>::Owned,
) -> Result<(), Error>
pub fn decode_into<T>( header: &TransactionHeader, buf: &'a [u8], handles: &'a mut [<<D as ResourceDialect>::Handle as HandleFor<D>>::HandleInfo], value: &mut <T as TypeMarker>::Owned, ) -> Result<(), Error>
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
.
pub fn decode_with_context<T>(
context: Context,
buf: &'a [u8],
handles: &'a mut [<<D as ResourceDialect>::Handle as HandleFor<D>>::HandleInfo],
value: &mut <T as TypeMarker>::Owned,
) -> Result<(), Error>
pub fn decode_with_context<T>( context: Context, buf: &'a [u8], handles: &'a mut [<<D as ResourceDialect>::Handle as HandleFor<D>>::HandleInfo], value: &mut <T as TypeMarker>::Owned, ) -> Result<(), Error>
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.
pub 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.
pub fn remaining_handles(&self) -> usize
pub fn remaining_handles(&self) -> usize
The number of handles that have not yet been consumed.
pub fn debug_check_bounds<T>(&self, offset: usize)where
T: TypeMarker,
pub fn debug_check_bounds<T>(&self, offset: usize)where
T: TypeMarker,
In debug mode only, asserts that there is enough room in the buffer to
read an object of type T
at offset
.
pub fn read_num<T>(&mut self, offset: usize) -> Twhere
T: Numeric,
pub fn read_num<T>(&mut self, offset: usize) -> Twhere
T: Numeric,
Decodes a primitive numeric type. The caller must ensure that self.buf
has room for reading T::inline_size
bytes as offset
.
pub unsafe fn out_of_line_offset(&mut self, len: usize) -> Result<usize, Error>
pub unsafe fn out_of_line_offset(&mut self, len: usize) -> Result<usize, Error>
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.
pub fn check_padding(&self, offset: usize, len: usize) -> Result<(), Error>
pub fn check_padding(&self, offset: usize, len: usize) -> Result<(), Error>
Checks that the specified padding bytes are in fact zeroes. Like
Decode::decode
, the caller is responsible for bounds checks.
pub fn check_inline_envelope_padding(
&self,
value_offset: usize,
value_len: usize,
) -> Result<(), Error>
pub fn check_inline_envelope_padding( &self, value_offset: usize, value_len: usize, ) -> Result<(), Error>
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.
pub fn take_next_handle(
&mut self,
expected_object_type: ObjectType,
expected_rights: Rights,
) -> Result<<D as ResourceDialect>::Handle, Error>
pub fn take_next_handle( &mut self, expected_object_type: ObjectType, expected_rights: Rights, ) -> Result<<D as ResourceDialect>::Handle, Error>
Take the next handle from the handles
list.
pub fn drop_next_handle(&mut self) -> Result<(), Error>
pub fn drop_next_handle(&mut self) -> Result<(), Error>
Drops the next handle in the handle array.