Skip to main content

CheckLedger

Struct CheckLedger 

Source
pub struct CheckLedger { /* private fields */ }
Expand description

Append/read handle for a workspace’s check ledger.

Implementations§

Source§

impl CheckLedger

Source

pub fn for_workspace(workspace_root: &Path) -> Self

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn transport_lines_for_mem(&self, mem: &str) -> Vec<u8> ⓘ

The transport form of one mem’s rows (Self::transport_lines).

Source

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.

Source

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.

Source

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:

  1. a carried line supersedes every record of the same entity and kind whose entity_hash is its carried_from.hash and 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;
  2. among the rest, the earlier time of the act comes first (CheckRecord::act_time);
  3. remaining ties are ordered by the rows’ canonical bytes, never by ledger position.
Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CheckLedger

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Fruit for T
where T: Send + Downcast,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more