Skip to main content

CachedFileStore

Struct CachedFileStore 

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

A file-backed store that also maintains a bounded in-memory cache of message bodies (FileStoreMaxCachedMsgs; 0 = unbounded), avoiding a disk read for cached resends.

Implementations§

Source§

impl CachedFileStore

Source

pub fn open(dir: &Path) -> Result<Self, StoreError>

Open (creating if needed) a cached file store in dir with default options (FileStoreSync=Y, unbounded cache — matching the original pre-FR-025 behavior).

Source

pub fn open_with_options( dir: &Path, options: FileStoreOptions, ) -> Result<Self, StoreError>

Open (creating if needed) a cached file store in dir with explicit options (FR-025). On open, the cache is warmed from the existing body log (most-recent messages first, up to max_cached_msgs).

Source

pub fn was_corrupted(&self) -> bool

Whether a corrupt trailing record was detected and recovered on open.

Source

pub fn cached_len(&self) -> Result<usize, StoreError>

The number of message bodies currently held in the in-memory cache.

Trait Implementations§

Source§

impl MessageStore for CachedFileStore

Source§

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

The next outbound (sender) sequence number.
Source§

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

The next inbound (target) sequence number expected.
Source§

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

Set the next outbound sequence number.
Source§

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

Set the next inbound sequence number.
Source§

fn save<'life0, 'life1, 'async_trait>( &'life0 self, seq: u64, message: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist an outbound message’s bytes under its sequence number.
Source§

fn get<'life0, 'async_trait>( &'life0 self, begin: u64, end: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<(u64, Vec<u8>)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve stored messages whose sequence numbers fall in [begin, end], in order.
Source§

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

Reset: clear stored messages and set both sequence numbers back to 1.
Source§

fn was_corrupted(&self) -> bool

Whether this store detected and recovered from corruption when it was opened (ForceResendWhenCorruptedStore). Backends with no corruption-detection concept (e.g. MemoryStore, NoopStore, SQL backends relying on the database’s own durability) default to false.
Source§

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

The wall-clock time this store was created (or last reset), if the backend tracks one (GAP-38/FR-017, feature 005). None for backends with no such concept (e.g. MemoryStore, NoopStore) or when not yet recorded.
Source§

fn save_and_advance_sender<'life0, 'life1, 'async_trait>( &'life0 self, seq: u64, message: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically persist an outbound message and advance the sender sequence past it (GAP-39/FR-018, feature 005): closes the crash window where save() succeeds but a subsequent set_next_sender_seq() doesn’t (or vice versa), which could otherwise double-send or skip a sequence number on restart. The default implementation preserves today’s behavior (two independent calls) for any backend that doesn’t override it.
Source§

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

Whether a message is already saved under seq (NEW-137, audit 006): a way for callers to observe duplicate sequence usage without changing save()’s existing overwrite-on-conflict contract (deliberately kept separate rather than having save() itself return an overwrote-something flag, to avoid a breaking signature change across every backend). Default Ok(false) for any backend that doesn’t override it.

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.