pub unsafe trait Reader<'r>: Sized {
Show 15 methods
// Required methods
fn read_i64(&mut self) -> Result<i64, ReadError>;
fn read_i32(&mut self) -> Result<i32, ReadError>;
fn read_i16(&mut self) -> Result<i16, ReadError>;
fn read_u64(&mut self) -> Result<u64, ReadError>;
fn read_u32(&mut self) -> Result<u32, ReadError>;
fn read_u16(&mut self) -> Result<u16, ReadError>;
fn read_f32(&mut self) -> Result<f32, ReadError>;
fn read_f64(&mut self) -> Result<f64, ReadError>;
fn read_opaque_fixed(&mut self, len: usize) -> Result<&'r [u8], ReadError>;
fn read_opaque_variable(&mut self, max: u32) -> Result<&'r [u8], ReadError>;
// Provided methods
fn read_bool(&mut self) -> Result<bool, ReadError> { ... }
fn read_opaque_fixed_into<'a>(
&mut self,
dst: &'a mut [MaybeUninit<u8>],
len: u32,
) -> Result<&'a mut [u8], ReadError> { ... }
fn read_opaque_variable_into<'a>(
&mut self,
dst: &'a mut [MaybeUninit<u8>],
max: u32,
) -> Result<&'a mut [u8], ReadError> { ... }
fn read_opaque_fixed_owned(
&mut self,
len: u32,
) -> Result<Vec<u8>, ReadError> { ... }
fn read_opaque_variable_owned(
&mut self,
max: u32,
) -> Result<Vec<u8>, ReadError> { ... }
}Expand description
A reader that can produce XDR values, some borrowed with lifetime 'r.
This trait provides methods for reading XDR primitive types from an
underlying serialization format. The lifetime parameter 'r represents
the lifetime of data borrowed from the reader.
Implementations of this trait are used by ReadXDR
to deserialize complex types.
§Safety
read_opaque_fixed must return a slice
of exactly len bytes on success. Unsafe code in this crate relies on
that invariant.
Required Methods§
Provided Methods§
Sourcefn read_opaque_fixed_into<'a>(
&mut self,
dst: &'a mut [MaybeUninit<u8>],
len: u32,
) -> Result<&'a mut [u8], ReadError>
fn read_opaque_fixed_into<'a>( &mut self, dst: &'a mut [MaybeUninit<u8>], len: u32, ) -> Result<&'a mut [u8], ReadError>
Reads a byte array of known length, copying into a provided buffer rather than borrowing from the reader.
Panics if dst.len() does not equal len as usize.
Sourcefn read_opaque_variable_into<'a>(
&mut self,
dst: &'a mut [MaybeUninit<u8>],
max: u32,
) -> Result<&'a mut [u8], ReadError>
fn read_opaque_variable_into<'a>( &mut self, dst: &'a mut [MaybeUninit<u8>], max: u32, ) -> Result<&'a mut [u8], ReadError>
Reads a byte sequence of variable length, copying into a provided buffer. rather than borrowing from the reader.
Panics if dst.len() is less than the actual length of the input data.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".