Skip to main content

BufReader

Struct BufReader 

Source
pub struct BufReader<'r> { /* private fields */ }
Expand description

A reader for TXS-encoded XDR data from a byte slice.

This reader implements the Reader trait for the TXS (Traditional XDR Serialization) format. It reads data from a byte slice and tracks the current position.

Implementations§

Source§

impl<'a> BufReader<'a>

Source

pub fn new(data: &'a [u8]) -> Self

Creates a new BufReader that reads from the given byte slice.

The reader starts at position 0.

Source

pub fn position(&self) -> usize

Returns the current read position in the buffer.

Source

pub fn remaining(&self) -> usize

Returns the number of bytes remaining to be read.

Source

pub fn remaining_slice(&self) -> &'a [u8] ⓘ

Returns a slice of the remaining unread bytes.

Trait Implementations§

Source§

impl<'r> Reader<'r> for BufReader<'r>

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. Read more
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.
Source§

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

Reads a signed 16-bit integer.
Source§

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

Reads an unsigned 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_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_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_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. Read more
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. Read more
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>. Read more
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>. Read more

Auto Trait Implementations§

§

impl<'r> Freeze for BufReader<'r>

§

impl<'r> RefUnwindSafe for BufReader<'r>

§

impl<'r> Send for BufReader<'r>

§

impl<'r> Sync for BufReader<'r>

§

impl<'r> Unpin for BufReader<'r>

§

impl<'r> UnsafeUnpin for BufReader<'r>

§

impl<'r> UnwindSafe for BufReader<'r>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> StaticIfNoAlloc for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.