Struct grin_core::ser::BufReader

source ·
pub struct BufReader<'a, B: Buf> { /* private fields */ }
Expand description

Protocol version-aware wrapper around a Buf impl

Implementations§

source§

impl<'a, B: Buf> BufReader<'a, B>

source

pub fn new(buf: &'a mut B, version: ProtocolVersion) -> Self

Construct a new BufReader

source

pub fn bytes_read(&self) -> u64

The total bytes read

source

pub fn body<T: Readable>(&mut self) -> Result<T, Error>

Convenience function to read from the buffer and deserialize

Trait Implementations§

source§

impl<'a, B: Buf> Reader for BufReader<'a, B>

source§

fn deserialization_mode(&self) -> DeserializationMode

The mode this reader is reading from
source§

fn read_u8(&mut self) -> Result<u8, Error>

Read a u8 from the underlying Read
source§

fn read_u16(&mut self) -> Result<u16, Error>

Read a u16 from the underlying Read
source§

fn read_u32(&mut self) -> Result<u32, Error>

Read a u32 from the underlying Read
source§

fn read_u64(&mut self) -> Result<u64, Error>

Read a u64 from the underlying Read
source§

fn read_i32(&mut self) -> Result<i32, Error>

Read a i32 from the underlying Read
source§

fn read_i64(&mut self) -> Result<i64, Error>

Read a i64 from the underlying Read
source§

fn read_bytes_len_prefix(&mut self) -> Result<Vec<u8>, Error>

Read a u64 len prefix followed by that number of exact bytes.
source§

fn read_fixed_bytes(&mut self, len: usize) -> Result<Vec<u8>, Error>

Read a fixed number of bytes from the underlying reader.
source§

fn expect_u8(&mut self, val: u8) -> Result<u8, Error>

Consumes a byte from the reader, producing an error if it doesn’t have the expected value
source§

fn protocol_version(&self) -> ProtocolVersion

Access to underlying protocol version to support version specific deserialization logic.
source§

fn read_empty_bytes(&mut self, length: usize) -> Result<(), Error>

Read a fixed number of “empty” bytes from the underlying reader. It is an error if any non-empty bytes encountered.

Auto Trait Implementations§

§

impl<'a, B> Freeze for BufReader<'a, B>

§

impl<'a, B> RefUnwindSafe for BufReader<'a, B>
where B: RefUnwindSafe,

§

impl<'a, B> Send for BufReader<'a, B>
where B: Send,

§

impl<'a, B> Sync for BufReader<'a, B>
where B: Sync,

§

impl<'a, B> Unpin for BufReader<'a, B>

§

impl<'a, B> !UnwindSafe for BufReader<'a, B>

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<T> UnsafeAny for T
where T: Any,