pub struct CheckLedger { /* private fields */ }Expand description
Append/read handle for a workspace’s check ledger.
Implementations§
Source§impl CheckLedger
impl CheckLedger
pub fn for_workspace(workspace_root: &Path) -> Self
Sourcepub fn record(&self, rec: &CheckRecord) -> Result<()>
pub fn record(&self, rec: &CheckRecord) -> Result<()>
Append one record. One write syscall of one complete line on
an O_APPEND handle — concurrent writers interleave whole
lines, never tear them. Errors propagate: a check that did not
persist must refuse at the surface.
Sourcepub fn record_local(&self, rec: CheckRecord) -> Result<CheckRecord>
pub fn record_local(&self, rec: CheckRecord) -> Result<CheckRecord>
Append one check this engine just made, stamped so it never ties
with an earlier act on the same entity: ts is the engine’s clock,
and when the entity’s newest act already sits at or up to
LOCAL_TIE_WINDOW_SECS past it (a re-check within the same
second as the last one, say after an edit), ts moves to one
second past that act. Whole-second clocks would otherwise tie the
two, and the tie would go to the rows’ bytes, which could stand
the check of the replaced content over the check just made. A
record whose caller stated observed_at is appended as stated:
the caller named the time of the act. Returns the record as
appended.
Sourcepub fn carry_rename(&self, old: &str, new: &str) -> Result<usize>
pub fn carry_rename(&self, old: &str, new: &str) -> Result<usize>
Carry every record of old across a rename to new: each line
keyed by the old id is appended again under the new id with
renamed_from set, in ledger order, as one write of whole lines.
The originals stay — the ledger is append-only and they remain the
record of what was checked under that id. Returns the number of
lines carried; zero (and no write) when the old id has none.
Sourcepub fn carry_transition(
&self,
entity: &str,
kind: &str,
pre_hash: &str,
post_hash: &str,
) -> Result<bool>
pub fn carry_transition( &self, entity: &str, kind: &str, pre_hash: &str, post_hash: &str, ) -> Result<bool>
Carry the record that licensed a status transition across the
write it licensed: the newest record of entity under the wire
kind is appended again with post_hash as its entity_hash and
carried_from: {hash: pre_hash, reason: "transition"}, if and
only if it is fresh at pre_hash and confirming (ok). A stale
or failed record is not carried (it did not license anything),
and equal hashes carry nothing. Every other field stays the
original act’s, identity included. Returns whether a line was
appended.
Sourcepub fn rows_for_mem(&self, mem: &str) -> Vec<CheckRecord>
pub fn rows_for_mem(&self, mem: &str) -> Vec<CheckRecord>
The records of one mem’s entities, in standing order
(Self::in_standing_order): every record whose entity id is
qualified by mem.
Sourcepub fn transport_lines_for_mem(&self, mem: &str) -> Vec<u8> ⓘ
pub fn transport_lines_for_mem(&self, mem: &str) -> Vec<u8> ⓘ
The transport form of one mem’s rows (Self::transport_lines).
Sourcepub fn transport_lines(records: &[CheckRecord]) -> Vec<u8> ⓘ
pub fn transport_lines(records: &[CheckRecord]) -> Vec<u8> ⓘ
The transport form of a set of records: one JSON line per record, ordered by timestamp then by the line’s bytes, exact duplicates dropped, a trailing newline. The same records give the same bytes on every machine, so a publish that changed nothing writes nothing.
Sourcepub fn merge_transport_lines(
&self,
lines: &[u8],
now: u64,
) -> Result<MergedRows>
pub fn merge_transport_lines( &self, lines: &[u8], now: u64, ) -> Result<MergedRows>
Union lines (the transport form, from another machine) into
this ledger: every record not already present is appended; a
record already present (the same bytes) is skipped, so a round
trip adds nothing. Unparseable lines are skipped. Rows keep every
field they arrived with: identity, role, hash, timestamps; nothing
is rewritten on import, and a merged row counts by its own fields
(its time of the act places it, never its arrival).
A row whose time of the act lies more than
OBSERVED_AT_SKEW_SECS ahead of now (the receiving engine’s
clock) is refused as a local record with such a time is, and named
in the outcome: ordered by time, a row from a machine with a wrong
clock would otherwise stand for good.
Sourcepub fn in_standing_order(&self) -> Vec<CheckRecord>
pub fn in_standing_order(&self) -> Vec<CheckRecord>
Every record, in standing order: the one order every reader of a standing folds, so the last row of any (entity, kind) group, and of any narrower group of one entity’s rows, is that group’s newest record. The order is derived from the rows alone, so two machines holding the same rows derive the same newest whatever order their ledgers hold them in:
- a carried line supersedes every record of the same entity and
kind whose
entity_hashis itscarried_from.hashand whose act is no later than the carried line’s (they are keyed to content the carry replaced; a check made later, after the content came back to that hash, is a new act) and that stand lower in the carry chain (CarriedFrom::depth); superseded rows come first; - among the rest, the earlier time of the act comes first
(
CheckRecord::act_time); - remaining ties are ordered by the rows’ canonical bytes, never by ledger position.
Sourcepub fn latest_for(&self, entity: &str) -> Option<CheckRecord>
pub fn latest_for(&self, entity: &str) -> Option<CheckRecord>
The newest record for one entity, of any kind
(Self::in_standing_order). State derivation is per (entity,
kind) — use Self::latest_for_kind there; this remains the
“what happened last” accessor.
Sourcepub fn latest_for_kind(
&self,
entity: &str,
kind: CheckKind,
) -> Option<CheckRecord>
pub fn latest_for_kind( &self, entity: &str, kind: CheckKind, ) -> Option<CheckRecord>
The newest record for one entity of one kind. A later check of the OTHER kind never supersedes it: the two derivations answer different questions.
Sourcepub fn latest_for_wire_kind(
&self,
entity: &str,
kind: &str,
) -> Option<CheckRecord>
pub fn latest_for_wire_kind( &self, entity: &str, kind: &str, ) -> Option<CheckRecord>
The newest record for one entity of one WIRE kind: an engine
kind resolves as Self::latest_for_kind (legacy kind-less
lines read as verification); a foreign x-<name> kind matches
the recorded kind verbatim. The lookup a transition_requires_self_check
gate declares its kind against.
Trait Implementations§
Source§impl Clone for CheckLedger
impl Clone for CheckLedger
Auto Trait Implementations§
impl Forget for CheckLedger
impl Freeze for CheckLedger
impl Move for CheckLedger
impl RefUnwindSafe for CheckLedger
impl Send for CheckLedger
impl Sync for CheckLedger
impl Unpin for CheckLedger
impl UnsafeUnpin for CheckLedger
impl UnwindSafe for CheckLedger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more