Skip to main content

Reader

Trait Reader 

Source
pub unsafe trait Reader<'r>: Sized {
Show 15 methods // Required methods fn read_i64(&mut self) -> ReadResult<i64>; fn read_i32(&mut self) -> ReadResult<i32>; fn read_i16(&mut self) -> ReadResult<i16>; fn read_u64(&mut self) -> ReadResult<u64>; fn read_u32(&mut self) -> ReadResult<u32>; fn read_u16(&mut self) -> ReadResult<u16>; fn read_f32(&mut self) -> ReadResult<f32>; fn read_f64(&mut self) -> ReadResult<f64>; fn read_opaque_fixed(&mut self, len: usize) -> ReadResult<&'r [u8]>; fn read_opaque_variable(&mut self, max: u32) -> ReadResult<&'r [u8]>; // Provided methods fn read_bool(&mut self) -> ReadResult<bool> { ... } fn read_opaque_fixed_into<'a>( &mut self, dst: &'a mut [MU<u8>], len: u32, ) -> ReadResult<&'a mut [u8]> { ... } fn read_opaque_variable_into<'a>( &mut self, dst: &'a mut [MU<u8>], max: u32, ) -> ReadResult<&'a mut [u8]> { ... } fn read_opaque_fixed_owned(&mut self, len: u32) -> ReadResult<Vec<u8>> { ... } fn read_opaque_variable_owned(&mut self, max: u32) -> ReadResult<Vec<u8>> { ... }
}
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§

Source

fn read_i64(&mut self) -> ReadResult<i64>

Reads a signed 64-bit integer.

Source

fn read_i32(&mut self) -> ReadResult<i32>

Reads a signed 32-bit integer.

Source

fn read_i16(&mut self) -> ReadResult<i16>

Reads a signed 16-bit integer.

Source

fn read_u64(&mut self) -> ReadResult<u64>

Reads an unsigned 64-bit integer.

Source

fn read_u32(&mut self) -> ReadResult<u32>

Reads an unsigned 32-bit integer.

Source

fn read_u16(&mut self) -> ReadResult<u16>

Reads an unsigned 16-bit integer.

Source

fn read_f32(&mut self) -> ReadResult<f32>

Reads a 32-bit IEEE 754 floating-point value.

Source

fn read_f64(&mut self) -> ReadResult<f64>

Reads a 64-bit IEEE 754 floating-point value.

Source

fn read_opaque_fixed(&mut self, len: usize) -> ReadResult<&'r [u8]>

Reads a byte array of known length, borrowing the contents from the reader.

On success, the returned slice must have exactly len bytes. Callers may rely on this invariant for soundness.

Source

fn read_opaque_variable(&mut self, max: u32) -> ReadResult<&'r [u8]>

Reads a byte sequence of variable length (not exceeding max), borrowing the contents from the reader.

Provided Methods§

Source

fn read_bool(&mut self) -> ReadResult<bool>

Reads a boolean value.

Source

fn read_opaque_fixed_into<'a>( &mut self, dst: &'a mut [MU<u8>], len: u32, ) -> ReadResult<&'a mut [u8]>

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.

Source

fn read_opaque_variable_into<'a>( &mut self, dst: &'a mut [MU<u8>], max: u32, ) -> ReadResult<&'a mut [u8]>

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.

Source

fn read_opaque_fixed_owned(&mut self, len: u32) -> ReadResult<Vec<u8>>

Available on crate feature alloc only.

Reads a byte array of known length, returning an owned Vec<u8>.

Requires feature alloc.

Source

fn read_opaque_variable_owned(&mut self, max: u32) -> ReadResult<Vec<u8>>

Available on crate feature alloc only.

Reads a byte sequence of variable length, returning an owned Vec<u8>.

Requires feature alloc.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'r> Reader<'r> for xdrs::cxs::buf_reader::BufReader<'r>

Source§

impl<'r> Reader<'r> for xdrs::txs::buf_reader::BufReader<'r>