Struct capsules_extra::log::Log
source · pub struct Log<'a, F: Flash + 'static> { /* private fields */ }
Implementations§
Trait Implementations§
source§impl<'a, F: Flash + 'static> Client<F> for Log<'a, F>
impl<'a, F: Flash + 'static> Client<F> for Log<'a, F>
source§fn write_complete(
&self,
pagebuffer: &'static mut F::Page,
result: Result<(), Error>,
)
fn write_complete( &self, pagebuffer: &'static mut F::Page, result: Result<(), Error>, )
If in the middle of a write operation, reset pagebuffer and finish write. If syncing, make successful client callback.
source§impl<'a, F: Flash + 'static> DeferredCallClient for Log<'a, F>
impl<'a, F: Flash + 'static> DeferredCallClient for Log<'a, F>
source§impl<'a, F: Flash + 'static> LogRead<'a> for Log<'a, F>
impl<'a, F: Flash + 'static> LogRead<'a> for Log<'a, F>
source§fn set_read_client(&self, read_client: &'a dyn LogReadClient)
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])>
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 next_read_entry_id(&self) -> Self::EntryID
fn next_read_entry_id(&self) -> Self::EntryID
Returns the ID of the next entry to be read.
source§fn seek(&self, entry_id: Self::EntryID) -> Result<(), ErrorCode>
fn seek(&self, entry_id: Self::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§impl<'a, F: Flash + 'static> LogWrite<'a> for Log<'a, F>
impl<'a, F: Flash + 'static> LogWrite<'a> for Log<'a, F>
source§fn set_append_client(&self, append_client: &'a dyn LogWriteClient)
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])>
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>
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>
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.