Skip to main content

Journal

Struct Journal 

Source
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>

Source

pub fn from_bytes_mut(data: &'a mut [u8]) -> Result<Self, ProgramError>

Parse a journal from a mutable byte slice.

Source

pub fn from_bytes(data: &[u8]) -> Result<JournalReader<'_, T>, ProgramError>

Create a read-only journal view.

Source

pub fn capacity(&self) -> usize

Maximum number of entries.

Source

pub fn write_head(&self) -> u32

Current write head position.

Source

pub fn total_written(&self) -> u32

Total entries ever written.

Source

pub fn flags(&self) -> u32

Journal flags.

Source

pub fn is_circular(&self) -> bool

Whether circular mode is enabled.

Source

pub fn has_wrapped(&self) -> bool

Whether the journal has wrapped at least once (total_written > capacity).

Source

pub fn entry_count(&self) -> usize

Number of valid entries (min of total_written and capacity).

Source

pub fn append(&mut self, entry: T) -> Result<(), ProgramError>

Append an entry to the journal.

Source

pub fn read(&self, index: usize) -> Result<T, ProgramError>

Read entry at logical index (0 = oldest visible entry).

Source

pub fn latest(&self) -> Result<T, ProgramError>

Read the most recent entry.

Source

pub const fn required_bytes(capacity: usize) -> usize

Bytes required for a journal with the given capacity.

Source

pub fn init(&mut self, circular: bool)

Initialize the journal header (circular or strict).

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> 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>,

Source§

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>,

Source§

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.