StoreBackend

Trait StoreBackend 

Source
pub trait StoreBackend {
    type Data: ?Sized + AsRef<[u8]>;
    type Error;

    // Required methods
    fn data(&self) -> &Self::Data;
    fn erase(&mut self) -> Result<(), Self::Error>;
    fn program(
        &mut self,
        offset: usize,
        payload: &[u8],
    ) -> Result<(), Self::Error>;
    fn backup_space(&self) -> &'static mut [u8];

    // Provided methods
    fn len(&self) -> usize { ... }
    fn program_done(&mut self) { ... }
}
Expand description

Backend interface for Store

Required Associated Types§

Source

type Data: ?Sized + AsRef<[u8]>

type returned by data() for reading the flash

Source

type Error

error type returned by erase()/flash() operations

Required Methods§

Source

fn data(&self) -> &Self::Data

memory-mapped

Source

fn erase(&mut self) -> Result<(), Self::Error>

erase flash page

Source

fn program(&mut self, offset: usize, payload: &[u8]) -> Result<(), Self::Error>

program flash with offset into flash page

Source

fn backup_space(&self) -> &'static mut [u8]

need for automatic compaction

leaves memory management to the implementer

Provided Methods§

Source

fn len(&self) -> usize

size of flash page

Source

fn program_done(&mut self)

called after repeated program() invocations to allow for eg. cache flushing

Implementors§