Trait yaxpeax_arch::Reader
source · [−]pub trait Reader<Address, Item> {
fn next(&mut self) -> Result<Item, ReadError>;
fn next_n(&mut self, buf: &mut [Item]) -> Result<(), ReadError>;
fn mark(&mut self);
fn offset(&mut self) -> Address;
fn total_offset(&mut self) -> Address;
}
Expand description
a trait defining how Item
-sized words are read at Address
-positioned offsets into some
stream of data. for most uses, crate::U8Reader
probably is sufficient. when
reading from data sources that aren’t &[u8]
, Address
isn’t a multiple of u8
, or Item
isn’t a multiple of 8 bits, U8Reader
won’t be sufficient.
Required Methods
fn next(&mut self) -> Result<Item, ReadError>
sourcefn next_n(&mut self, buf: &mut [Item]) -> Result<(), ReadError>
fn next_n(&mut self, buf: &mut [Item]) -> Result<(), ReadError>
read buf
-many items from this reader in bulk. if Reader
cannot read buf
-many items,
return ReadError::ExhaustedInput
.
sourcefn offset(&mut self) -> Address
fn offset(&mut self) -> Address
the difference, in Address
, between the current Reader
position and its last mark
.
when created, a Reader
’s initial position is mark
ed, so creating a Reader
and
immediately calling offset()
must return Address::zero()
.
sourcefn total_offset(&mut self) -> Address
fn total_offset(&mut self) -> Address
the difference, in Address
, between the current Reader
position and the initial offset
when constructed.