Skip to main content

MemoryJournal

Struct MemoryJournal 

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

In-memory journal backed by a ring buffer.

Useful for development, testing, and short-lived routers that don’t need persistence across restarts.

Implementations§

Source§

impl MemoryJournal

Source

pub fn new(capacity: usize) -> Self

Create a new memory journal with the given capacity.

Source

pub fn default_capacity() -> Self

Create with default capacity (10,000 entries)

Trait Implementations§

Source§

impl Journal for MemoryJournal

Source§

fn append<'life0, 'async_trait>( &'life0 self, entry: JournalEntry, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Append an entry to the journal. Returns the assigned sequence number.
Source§

fn query<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, pattern: &'life1 str, from: Option<u64>, to: Option<u64>, limit: Option<u32>, types: &'life2 [SignalType], ) -> Pin<Box<dyn Future<Output = Result<Vec<JournalEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Query entries matching a pattern within a time range.
Source§

fn since<'life0, 'async_trait>( &'life0 self, seq: u64, limit: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<Vec<JournalEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get entries since a given sequence number.
Source§

fn latest_seq<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the latest sequence number.
Source§

fn snapshot<'life0, 'life1, 'async_trait>( &'life0 self, state: &'life1 [ParamSnapshot], ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save a state snapshot for faster recovery.
Source§

fn load_snapshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ParamSnapshot>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load the most recent snapshot.
Source§

fn compact<'life0, 'async_trait>( &'life0 self, before_seq: u64, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove entries older than the given sequence number. Returns the number of entries removed.
Source§

fn len<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the total number of entries in the journal.
Source§

fn is_empty<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check whether the journal is empty.

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