Skip to main content

Journal

Struct Journal 

Source
pub struct Journal { /* private fields */ }
Expand description

In-memory journal with optional durable path.

Maturity: core

Implementations§

Source§

impl Journal

Source

pub const fn new(path: Option<PathBuf>) -> Self

Empty journal, optionally bound to a path for appends.

Source

pub fn load(path: PathBuf) -> Result<Self, JournalError>

Load from jsonl path (missing file => empty bound journal).

§Errors

Returns parse/IO/unsafe-restore errors. Torn final lines are repaired (completed with \n when valid JSON, otherwise truncated).

Source

pub const fn len(&self) -> usize

Number of entries.

Source

pub const fn is_empty(&self) -> bool

Empty check.

Source

pub const fn bytes(&self) -> u64

Durable byte length (header + lines, after repairs).

Source

pub fn agent_reservation_count(&self) -> u64

Count of recorded spawn_agent entries (reservation accounting helper).

Source

pub fn covers(&self, seq: u64) -> bool

Whether seq is already covered.

Source

pub fn replay( &self, seq: u64, kind: &str, hash: &str, ) -> Result<Option<Value>, JournalError>

Replay a covered call or return None to execute live.

§Errors

Divergence when kind/hash mismatch.

Source

pub fn record( &mut self, seq: u64, kind: &str, hash: String, result: Value, ) -> Result<(), JournalError>

Append a live result.

§Errors

Full journal, sequence errors, or IO failures.

Source

pub fn prune_trailing_host_error( &mut self, failure_detail: &str, ) -> Result<bool, JournalError>

Drop the trailing host-error sentinel when it matches failure_detail.

Used so a recoverable host failure can be retried on resume without replaying the same error. Safe to call repeatedly: each successful prune restores the prior entry’s line offset.

§Errors

IO failures while truncating the durable file.

Source

pub fn prune_trailing_host_errors( &mut self, failure_detail: &str, ) -> Result<usize, JournalError>

Drop trailing host-error sentinels while failure_detail matches the current last entry’s message (repeated prune).

§Errors

IO failures while truncating.

Source

pub fn path(&self) -> Option<&Path>

Optional durable path.

Source

pub fn entries(&self) -> &[JournalEntry]

Entries as a slice (for inspection / tests).

Trait Implementations§

Source§

impl Debug for Journal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Journal

Source§

fn default() -> Journal

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.