mem-storage
mem-storage is an abstraction over a chunk of memory, that is readable and writable. It can be used in in everything, that requires some sort of memory, e.g. the RAM in an emulator. This crate can also be used in no_std environment.
Motivation
Every time I write an emulator, I don't like to make
a struct Memory
over and over again and always copy paste methods like
read_u8
, read_u16
, etc. So I came up with a generic solution for this problem.
Usage
Use the MemoryStorage trait
use MemoryStorage;
let mem = new;
/// The `read` and `write` method will read / write data using little endian format.
/// For big endian format use `read_be` and `write_be`.
mem.write;
let value = mem.;
assert_eq!;
mem.write;
let value = mem.;
assert_eq!;
mem.write_be;
let value = mem.;
assert_eq!;
Implement the MemoryStorage trait
use MemoryStorage;
/// This time your struct is responsible for storing the data.
License
This project is double-licensed under the Zlib or Apache2.0 license.