Trait yaxpeax_arch::Reader[][src]

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, [yaxpeax_arch::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

read buf-many items from this reader in bulk. if Reader cannot read buf-many items, return ReadError::ExhaustedInput.

mark the current position as where to measure offset against.

the difference, in Address, between the current Reader position and its last mark. when created, a Reader’s initial position is marked, so creating a Reader and immediately calling offset() must return Address::zero().

the difference, in Address, between the current Reader position and the initial offset when constructed.

Implementors