Struct grin_core::ser::StreamingReader
source · pub struct StreamingReader<'a> { /* private fields */ }
Expand description
A reader that reads straight off a stream. Tracks total bytes read so we can verify we read the right number afterwards.
Implementations§
source§impl<'a> StreamingReader<'a>
impl<'a> StreamingReader<'a>
sourcepub fn new(
stream: &'a mut dyn Read,
version: ProtocolVersion
) -> StreamingReader<'a>
pub fn new( stream: &'a mut dyn Read, version: ProtocolVersion ) -> StreamingReader<'a>
Create a new streaming reader with the provided underlying stream. Also takes a duration to be used for each individual read_exact call.
sourcepub fn total_bytes_read(&self) -> u64
pub fn total_bytes_read(&self) -> u64
Returns the total bytes read via this streaming reader.
Trait Implementations§
source§impl<'a> Reader for StreamingReader<'a>
impl<'a> Reader for StreamingReader<'a>
Note: We use read_fixed_bytes() here to ensure our “async” I/O behaves as expected.
source§fn read_bytes_len_prefix(&mut self) -> Result<Vec<u8>, Error>
fn read_bytes_len_prefix(&mut self) -> Result<Vec<u8>, Error>
Read a variable size vector from the underlying stream. Expects a usize
source§fn read_fixed_bytes(&mut self, len: usize) -> Result<Vec<u8>, Error>
fn read_fixed_bytes(&mut self, len: usize) -> Result<Vec<u8>, Error>
Read a fixed number of bytes.
source§fn deserialization_mode(&self) -> DeserializationMode
fn deserialization_mode(&self) -> DeserializationMode
The mode this reader is reading from
source§fn expect_u8(&mut self, val: u8) -> Result<u8, Error>
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
fn protocol_version(&self) -> ProtocolVersion
Access to underlying protocol version to support
version specific deserialization logic.
Auto Trait Implementations§
impl<'a> Freeze for StreamingReader<'a>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more