Type Alias Log

Source
type Log = Log<'static, Nvmc>;

Aliased Type§

struct Log { /* private fields */ }

Implementations

Source§

impl<'a, F> Log<'a, F>
where F: Flash + 'static,

Source

pub fn new( volume: &'static [u8], driver: &'a F, pagebuffer: &'static mut <F as Flash>::Page, circular: bool, ) -> Log<'a, F>

Trait Implementations

Source§

impl<F> Client<F> for Log<'_, F>
where F: Flash + 'static,

Source§

fn write_complete( &self, pagebuffer: &'static mut <F as Flash>::Page, result: Result<(), Error>, )

If in the middle of a write operation, reset pagebuffer and finish write. If syncing, make successful client callback.

Source§

fn erase_complete(&self, result: Result<(), Error>)

Erase next page if log erase complete, else make client callback. Fails with BUSY if flash is busy and erase cannot be completed.

Source§

fn read_complete( &self, _read_buffer: &'static mut <F as Flash>::Page, _result: Result<(), Error>, )

Flash read complete.
Source§

impl<F> DeferredCallClient for Log<'_, F>
where F: Flash + 'static,

Source§

fn handle_deferred_call(&self)

Software interrupt function that is called when the deferred call is triggered.
Source§

fn register(&'static self)

Source§

impl<'a, F> LogRead<'a> for Log<'a, F>
where F: Flash + 'static,

Source§

fn set_read_client(&self, read_client: &'a dyn LogReadClient)

Set the client for read operation callbacks.

Source§

fn read( &self, buffer: &'static mut [u8], length: usize, ) -> Result<(), (ErrorCode, &'static mut [u8])>

Read an entire log entry into a buffer, if there are any remaining. Updates the read entry ID to point at the next entry when done. Returns: * Ok(()) on success. * Err((Result<(), ErrorCode>, Option<buffer>)) on failure. The buffer will only be None if the error is due to a loss of the buffer. Result<(), ErrorCode>s used: * FAIL: reached end of log, nothing to read. * BUSY: log busy with another operation, try again later. * INVAL: provided client buffer is too small. * CANCEL: invalid internal state, read entry ID was reset to start of log. * RESERVE: client or internal pagebuffer missing. * SIZE: buffer not large enough to contain entry being read. Result<(), ErrorCode>s used in read_done callback: * Ok(()): read succeeded.

Source§

fn log_start(&self) -> <Log<'a, F> as LogRead<'a>>::EntryID

Returns the ID of the oldest remaining entry in the log.

Source§

fn log_end(&self) -> <Log<'a, F> as LogRead<'a>>::EntryID

Returns the ID of the newest entry in the log.

Source§

fn next_read_entry_id(&self) -> <Log<'a, F> as LogRead<'a>>::EntryID

Returns the ID of the next entry to be read.

Source§

fn seek( &self, entry_id: <Log<'a, F> as LogRead<'a>>::EntryID, ) -> Result<(), ErrorCode>

Seek to a new read entry ID. It is only legal to seek to entry IDs retrieved through the log_start(), log_end(), and next_read_entry_id() functions. Result<(), ErrorCode>s used: * Ok(()): seek succeeded. * INVAL: entry ID not valid seek position within current log. * RESERVE: no log client set.

Source§

fn get_size(&self) -> usize

Get approximate log capacity in bytes.

Source§

type EntryID = usize

Unique identifier for log entries.
Source§

impl<'a, F> LogWrite<'a> for Log<'a, F>
where F: Flash + 'static,

Source§

fn set_append_client(&self, append_client: &'a dyn LogWriteClient)

Set the client for append operation callbacks.

Source§

fn append( &self, buffer: &'static mut [u8], length: usize, ) -> Result<(), (ErrorCode, &'static mut [u8])>

Appends an entry onto the end of the log. Entry must fit within a page (including log metadata). Returns: * Ok(()) on success. * Err((Result<(), ErrorCode>, Option<buffer>))1 on failure. The buffer will only be Noneif the error is due to a loss of the buffer.Result<(), ErrorCode>s used: * FAIL: end of non-circular log reached, cannot append any more entries. * BUSY: log busy with another operation, try again later. * INVAL: provided client buffer is too small. * RESERVE: client or internal pagebuffer missing. * SIZE: entry too large to append to log. Result<(), ErrorCode>s used in append_done callback: * Ok(()): append succeeded. * FAIL: write failed due to flash error. * CANCEL`: write failed due to reaching the end of a non-circular log.

Source§

fn sync(&self) -> Result<(), ErrorCode>

Sync log to storage. Result<(), ErrorCode>s used: * Ok(()): flush started successfully. * FAIL: flash driver not configured. * BUSY: log or flash driver busy, try again later. * RESERVE: no log client set. Result<(), ErrorCode>s used in sync_done callback: * Ok(()): append succeeded. * FAIL: write failed due to flash error.

Source§

fn erase(&self) -> Result<(), ErrorCode>

Erase the entire log. Result<(), ErrorCode>s used: * Ok(()): flush started successfully. * BUSY: log busy, try again later. Result<(), ErrorCode>s used in erase_done callback: * Ok(()): erase succeeded. * BUSY: erase interrupted by busy flash driver. Call erase again to resume.