pub struct Journal<'a, T: Pod + FixedLayout> { /* private fields */ }Expand description
An append-only journal of fixed-size entries.
Implementations§
Source§impl<'a, T: Pod + FixedLayout> Journal<'a, T>
impl<'a, T: Pod + FixedLayout> Journal<'a, T>
Sourcepub fn from_bytes_mut(data: &'a mut [u8]) -> Result<Self, ProgramError>
pub fn from_bytes_mut(data: &'a mut [u8]) -> Result<Self, ProgramError>
Parse a journal from a mutable byte slice.
Sourcepub fn from_bytes(data: &[u8]) -> Result<JournalReader<'_, T>, ProgramError>
pub fn from_bytes(data: &[u8]) -> Result<JournalReader<'_, T>, ProgramError>
Create a read-only journal view.
Sourcepub fn write_head(&self) -> u32
pub fn write_head(&self) -> u32
Current write head position.
Sourcepub fn total_written(&self) -> u32
pub fn total_written(&self) -> u32
Total entries ever written.
Sourcepub fn is_circular(&self) -> bool
pub fn is_circular(&self) -> bool
Whether circular mode is enabled.
Sourcepub fn has_wrapped(&self) -> bool
pub fn has_wrapped(&self) -> bool
Whether the journal has wrapped at least once (total_written > capacity).
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Number of valid entries (min of total_written and capacity).
Sourcepub fn append(&mut self, entry: T) -> Result<(), ProgramError>
pub fn append(&mut self, entry: T) -> Result<(), ProgramError>
Append an entry to the journal.
Sourcepub fn read(&self, index: usize) -> Result<T, ProgramError>
pub fn read(&self, index: usize) -> Result<T, ProgramError>
Read entry at logical index (0 = oldest visible entry).
Sourcepub fn latest(&self) -> Result<T, ProgramError>
pub fn latest(&self) -> Result<T, ProgramError>
Read the most recent entry.
Sourcepub const fn required_bytes(capacity: usize) -> usize
pub const fn required_bytes(capacity: usize) -> usize
Bytes required for a journal with the given capacity.
Auto Trait Implementations§
impl<'a, T> Freeze for Journal<'a, T>
impl<'a, T> RefUnwindSafe for Journal<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Journal<'a, T>where
T: Send,
impl<'a, T> Sync for Journal<'a, T>where
T: Sync,
impl<'a, T> Unpin for Journal<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for Journal<'a, T>
impl<'a, T> !UnwindSafe for Journal<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more