Struct grin_core::ser::StreamingReader[][src]

pub struct StreamingReader<'a> { /* fields omitted */ }

A reader that reads straight off a stream. Tracks total bytes read so we can verify we read the right number afterwards.

Implementations

impl<'a> StreamingReader<'a>[src]

pub fn new(
    stream: &'a mut dyn Read,
    version: ProtocolVersion
) -> StreamingReader<'a>
[src]

Create a new streaming reader with the provided underlying stream. Also takes a duration to be used for each individual read_exact call.

pub fn total_bytes_read(&self) -> u64[src]

Returns the total bytes read via this streaming reader.

Trait Implementations

impl<'a> Reader for StreamingReader<'a>[src]

Note: We use read_fixed_bytes() here to ensure our “async” I/O behaves as expected.

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

Read a variable size vector from the underlying stream. Expects a usize

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

Read a fixed number of bytes.

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

Read a u8 from the underlying Read

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

Read a u16 from the underlying Read

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

Read a u32 from the underlying Read

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

Read a i32 from the underlying Read

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

Read a u64 from the underlying Read

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

Read a i64 from the underlying Read

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

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

fn protocol_version(&self) -> ProtocolVersion[src]

Access to underlying protocol version to support version specific deserialization logic. Read more

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

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

Auto Trait Implementations

impl<'a> !RefUnwindSafe for StreamingReader<'a>

impl<'a> !Send for StreamingReader<'a>

impl<'a> !Sync for StreamingReader<'a>

impl<'a> Unpin for StreamingReader<'a>

impl<'a> !UnwindSafe for StreamingReader<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> UnsafeAny for T where
    T: Any