Skip to main content

Crate truefix_store

Crate truefix_store 

Source
Expand description

truefix-store — pluggable persistence of sequence numbers and sent messages.

The MessageStore trait abstracts the storage needed for resend (FR-G2): the next inbound and outbound sequence numbers, and the bytes of each sent message keyed by sequence number. Implementations: MemoryStore, FileStore, CachedFileStore, NoopStore, and a SQL-backed store behind the sql feature.

Audit 006 additions: MessageStore::contains exposes duplicate-sequence detection without changing save()’s existing overwrite-on-conflict contract (NEW-137); FileStoreOptions::max_body_records bounds a file-backed store’s body-log index while preserving resend/recovery semantics (NEW-108); Mongo/SQL/MSSQL reset() is atomic across messages and sequence numbers (NEW-116); and NoopStore tracks sequence numbers in memory for the session lifetime (NEW-118).

Feature 012 (audit 007) additions / migration note: StoreConfig gained a Custom(Arc<dyn MessageStore>) variant (NEW-158), letting a caller supply a backend not on the built-in list through the same config surface Engine::start resolves (see truefix::Engine::start_with_overrides). This is additive to the variant set, but StoreConfig can no longer derive Debug (dyn MessageStore isn’t Debug) – it now has a hand-written Debug impl with the same output for every pre-existing variant, so this only breaks code that exhaustively matches StoreConfig without a _ => arm.

Design: specs/001-fix-engine-parity/, specs/012-audit-007-remediation/.

Structs§

CachedFileStore
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.
FileStore
A durable, file-backed message store with no in-memory message-body cache (bodies are read from disk on every get()).
FileStoreOptions
Options shared by FileStore and CachedFileStore (FR-025).
MemoryStore
An in-memory store (does not survive process restart).
NoopStore
A no-op store: sequence numbers are tracked in memory for the session’s lifetime (matching QFJ’s own NoopStore, NEW-118/audit 006 – previously always reported 1 regardless of set_next_*_seq calls) but nothing else is persisted; save/get are no-ops.

Enums§

StoreConfig
Which store backend to construct.
StoreError
An error from a message store.

Traits§

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

Functions§

build_store
Build a boxed MessageStore from a StoreConfig.