Struct capsules_extra::log::Log

source ·
pub struct Log<'a, F: Flash + 'static> { /* private fields */ }

Implementations§

source§

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

source

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

Trait Implementations§

source§

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

source§

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§

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::Page, _result: Result<(), Error>, )

Flash read complete.
source§

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

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: Flash + 'static> LogRead<'a> for Log<'a, F>

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) -> Self::EntryID

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

source§

fn log_end(&self) -> Self::EntryID

Returns the ID of the newest entry in the log.

source§

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>

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.

§

type EntryID = usize

Unique identifier for log entries.
source§

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

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.

Auto Trait Implementations§

§

impl<'a, F> !Freeze for Log<'a, F>

§

impl<'a, F> !RefUnwindSafe for Log<'a, F>

§

impl<'a, F> !Send for Log<'a, F>

§

impl<'a, F> !Sync for Log<'a, F>

§

impl<'a, F> Unpin for Log<'a, F>

§

impl<'a, F> !UnwindSafe for Log<'a, F>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.