kernel::hil::log

Trait LogRead

Source
pub trait LogRead<'a> {
    type EntryID;

    // Required methods
    fn set_read_client(&'a self, read_client: &'a dyn LogReadClient);
    fn read(
        &self,
        buffer: &'static mut [u8],
        length: usize,
    ) -> Result<(), (ErrorCode, &'static mut [u8])>;
    fn log_start(&self) -> Self::EntryID;
    fn log_end(&self) -> Self::EntryID;
    fn next_read_entry_id(&self) -> Self::EntryID;
    fn seek(&self, entry: Self::EntryID) -> Result<(), ErrorCode>;
    fn get_size(&self) -> usize;
}
Expand description

An interface for reading from log storage.

Required Associated Types§

Source

type EntryID

Unique identifier for log entries.

Required Methods§

Source

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

Set the client for reading from a log. The client will be called when reading operations complete.

Source

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

Read the next entry from the log. The log advances to the next entry after a successful read. State does not change in the event of a failure.

Source

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

Returns the entry ID at the start of the log. This is the ID of the oldest remaining entry.

Source

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

Returns the entry ID at the end of the log. This is the ID of the next entry to be appended.

Source

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

Returns the ID of the next entry to be read.

Source

fn seek(&self, entry: Self::EntryID) -> Result<(), ErrorCode>

Seek to the entry with the given entry ID and begin reading from there. Fails without modifying the read position if the given entry ID is invalid or no longer in the log.

Source

fn get_size(&self) -> usize

Get approximate log capacity in bytes.

Implementors§