embedded-storage-file 0.2.0

file and in-memory interface for embedded-storage and embedded-storage-async
Documentation
[![Crates.io](https://img.shields.io/crates/v/embedded-storage-file.svg)](https://crates.io/crates/embedded-storage-file)
[![Released API docs](https://docs.rs/embedded-storage-file/badge.svg)](https://docs.rs/embedded-storage-file)

# embedded-storage-file

Library exposes traits from [embedded_storage](https://docs.rs/embedded-storage) and [embedded_storage_async](https://docs.rs/embedded-storage-async).
Exposed interface works as NOR flash where file is used as a storage medium.
Under the hood we use memory mapped file from [memmap2](https://docs.rs/memmap2).

Interface for using just in-memory (aka RAM) is also available.

Main use case is for testing and development purpose, so that we can mock NOR storage.


## In file example

```
use embedded_storage::{ReadStorage, Storage};
use embedded_storage_file::NorMemoryInFile;

let path = "tests/test1.nor";
let capacity = 4096;
// create nor interface that implements traits from embedded-storage::nor_flash
let nor = NorMemoryInFile::<
    256, // READ_SIZE
    256, // WRITE_SIZE
    256, // ERASE_SIZE
>::new(path, capacity)
.unwrap();
// convert to storage that implements embedded-storage::Storage
let mut storage = nor.storage();
// write & read 512 bytes from offset 128
let vin = vec![0x55u8; 512];
storage.write(128, &vin).unwrap();
let mut vread = vec![0u8; 512];
storage.read(128, &mut vread).unwrap();
assert_eq!(vin, vread);
std::fs::remove_file(path).unwrap();
```

# other examples

For other usecase examples check [tests/integration_test.rs](https://github.com/ra1u/embedded-storage-file/blob/master/tests/integration_test.rs).

# Changelog

See [CHANGELOG.md](https://github.com/ra1u/embedded-storage-file/blob/master/CHANGELOG.md) for release notes.