Skip to main content

MessageStore

Trait MessageStore 

Source
pub trait MessageStore: Send + Sync {
    // Required methods
    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;
    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;
    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;
    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;
    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;
    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;
    fn reset<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn was_corrupted(&self) -> bool { ... }
    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 { ... }
    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 { ... }
    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 { ... }
}
Expand description

Persistence for sequence numbers and outbound messages, sufficient to satisfy resend across restarts (FR-G2, SC-006).

Required Methods§

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.

Provided Methods§

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MessageStore for Arc<dyn MessageStore>

NEW-158 (feature 012): lets a StoreConfig::Custom(Arc<dyn MessageStore>) be handed to build_store and used exactly like any built-in backend, mirroring truefix_log’s impl Log for Box<dyn Log>.

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,

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,

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,

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,

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,

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,

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,

Source§

fn was_corrupted(&self) -> bool

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,

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,

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,

Implementors§