Skip to main content

Crate kivi

Crate kivi 

Source
Expand description

kivi Rust SDK — the untrusting client for the kivi event ledger.

The SDK constitution, enforced here and tested by the conformance suite:

  • an answer without a trace is UNREPRESENTABLE (TracedAnswer::new refuses an empty trace);
  • client-side verification is ON by default: replay re-hashes every record, checks chain linkage and gapless numbering, and verifies Ed25519 seals — a lying server or wire returns KiviError::Verification;
  • honest refusals map to a typed KiviError — NotFound is never a silent None;
  • identity: a bearer token at dial time, login() for kivi-user sessions, and with_bearer() views for per-caller credentials over one shared channel — the server decides everything, per call.

Numbers travel as JSON strings end to end and are decoded with serde_json, whose default Number holds any i64/u64 exactly (no float detour) — int64 values round-trip exactly (conformance S2).

Modules§

pb

Structs§

ChainChecker
Verifies a replay stream record by record: hash, gapless numbering, chain linkage and (optionally) Ed25519 seals. A lying stream returns KiviError::Verification — the server or the wire cannot get away with it.
Client
The kivi client for Rust. Async-first (tokio). Cheap to clone: clones share the underlying channel (tonic channels are already connection-pooled and cloneable), and with_bearer gives a clone with its OWN credential.
GraphEdge
One directed, traced relation edge: source —relation→ target, set by record no.
GraphHop
One step of a path: from —relation→ to, via edge record no.
GraphReached
A node found by a traversal, with its depth and the edge record numbers along the shortest discovering path (the proof).
Head
The cheap orientation answer: last record number + head hash (no audit).
Receipt
The proof of a write: record number, byte offset, hash.
RecordIntegrityChecker
Subscribe’s checker (G14): each record’s OWN hash/signature is verified, but — unlike ChainChecker — numbering gaps and prev_hash discontinuities are EXPECTED (server-side type filtering causes them by design) and are never treated as tampering.
Session
The result of a login: the bearer token plus its honest envelope.
SimilarAnswer
SimilarHit
One traced similarity hit: the record’s address, its score, and the raw receipt itself — an untraced score does not exist.
TracedAnswer
Value + the events that established it + the ledger scope it was derived from. Constructing one without a trace is refused — by design (the whole point of the second constitutional rule above).
VerifyReport
Mirrors the server’s dataset-wide audit.
ViewEntry
One row of a paged view read: canonical key + decoded value (trace inside).
ViewPage
One page of a keyset walk over a compiled view. next_key empty = done. scope/hash stamp the SNAPSHOT: pass scope back as as_of and every later page keeps describing that same moment.
ViewState
A whole compiled view plus its canonical digest.

Enums§

KiviError
Honest refusals, typed. NotFound is never a fabricated None.

Functions§

body_as
Decode an already-fetched record’s BODY into a TYPED entity T — the “entity out” for records from replay, subscribe, why or get_record. Zero extra dependency (serde).