Skip to main content

Ledger

Trait Ledger 

Source
pub trait Ledger {
    type Row;
    type Error;

    // Required methods
    fn record(&mut self, rows: &[Self::Row]) -> Result<(), Self::Error>;
    fn record_async(
        &mut self,
        rows: &[Self::Row],
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Available on crate feature runtime only.
Expand description

A node’s OWN control store — where its completion rows land when it has no durable position to land them with.

Positions is the sibling and the commoner case: a node that can re-read itself keeps a cursor, and its completion row is written in the transaction that moves it. A CHANNEL-fed node has no cursor — its inputs came from a sender it cannot ask again — so there is nothing for its row to be atomic WITH, and a single-row upsert stands alone.

§It is not the diagnostic half, and the difference is what may hold the loop

Attributes::observe queues and returns, and a full queue drops. This does neither: the row is the node’s own completion, the write happens before the ack it certifies goes out, and a refusal makes the delivery a failure exactly as a refused content write does. That is the whole content of the word STRONG — a journal that could be dropped could not be read as an answer to did this node finish this root.

&mut self for AsyncLands’ reason: a control store holds a connection, and a keyed replace over a page is not atomic across two callers.

§TWO SPELLINGS of one write, which is Intake’s arrangement one seam over

record is the THREAD engine’s door and record_async is the ASYNC engine’s, exactly as park and park_async already are. The thread engine’s landing runs on a thread it owns and can write there directly, so it calls the first and drives no future at all; the async engine awaits the second. One verb in a future shape would have made the thread engine’s landing spend a block_on for a write it was standing right next to.

What that costs an IMPLEMENTOR is one extra body, and the shape of it is the backend’s own answer rather than this trait’s. A blocking store writes in record and wraps a ready in record_async; a store whose only face is a future does the reverse and states its own blocking posture in record’s doc — SqlitePositions is that case in the tree.

Required Associated Types§

Source

type Row

The row this store keeps — the deployment’s own declared record.

Source

type Error

What a refused write reports.

Required Methods§

Source

fn record(&mut self, rows: &[Self::Row]) -> Result<(), Self::Error>

Upsert rows by their own (root, node) key, atomically — the THREAD engine’s door.

It ANSWERS rather than handing back a future, which is what lets the thread engine’s landing write where it stands.

Source

fn record_async( &mut self, rows: &[Self::Row], ) -> impl Future<Output = Result<(), Self::Error>> + Send

record as a future — the ASYNC engine’s door, and the same upsert.

Send because it is awaited from inside a resident, and residents are tasks on somebody’s runtime. Spelled as impl Future + Send rather than async fn, so the bound is part of the contract instead of something each caller has to hope for.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Ledger for ()

The unused control store — what a node that declared none carries.

AsyncLands for ()’ face, and the same argument: a resident is generic over its control store, so the absence of one has to be a type. It records nothing, which is not a claim that a row was written — it is the absence of a claim, and a node carrying it stages no row through this seam.

Source§

type Error = !

Source§

type Row = ()

Source§

fn record(&mut self, _rows: &[()]) -> Result<(), Self::Error>

Source§

fn record_async( &mut self, _rows: &[()], ) -> impl Future<Output = Result<(), Self::Error>> + Send

Implementors§

Source§

impl Ledger for SqlitePositions

Available on crate feature sqlite only.

The floor keeps positions and nothing else. A control store that also keeps a JOURNAL is a second table on this same connection, and its row type is the deployment’s own declared record — see JournalRow, which is what a control store’s Row has to be buildable through.

Source§

impl<K> Ledger for RecordedPositions<K>
where K: Send,