Skip to main content

open_with_receipts

Function open_with_receipts 

Source
pub fn open_with_receipts(
    db_path: impl AsRef<Path>,
    receipts_mode: ReceiptsMode,
) -> Result<(TraceSender, Option<SpillHandle>, JoinHandle<()>), StoreError>
Expand description

Open the SQLite trace database with the given receipts mode, migrate its schema, and spawn the background writer task.

Returns a TraceSender, an optional SpillHandle (present only in durable mode, for use by append_to_spill on channel-full), and the writer’s JoinHandle.

In ReceiptsMode::Durable mode the writer drains any existing spill file at startup and whenever the channel empties, inserting spilled traces BEFORE new channel arrivals so the hash chain stays append-only and valid across crashes and restarts.

§Errors

Returns StoreError::Sqlite if the database cannot be opened or migrated, or StoreError::Io if the spill file cannot be created in durable mode.