pub trait ByteReadable<Ptr> {
// Required methods
fn read(&self, ptr: &mut Ptr) -> Option<u8>;
fn has_next(&self, ptr: &Ptr) -> bool;
// Provided methods
fn read_n(&self, ptr: &mut Ptr, n: usize) -> Option<Vec<u8>> { ... }
fn read_u16(&self, ptr: &mut Ptr) -> Option<u16> { ... }
fn read_u32(&self, ptr: &mut Ptr) -> Option<u32> { ... }
fn read_i32(&self, ptr: &mut Ptr) -> Option<i32> { ... }
}
Expand description
Something that is readable with a pointer
Pointer Ptr
should contain the current reading position
which should be mutated after each read.