pub struct Record {
pub key: RecordKey,
pub kind: RecordKind,
pub revision: Revision,
pub parent: Option<Revision>,
pub body: Body,
pub meta: Meta,
pub links: Vec<RecordKey>,
pub ancestors: Vec<Revision>,
pub deleted_at: Option<i64>,
pub deleted_blob: Option<ContentHash>,
pub deleted_kind: Option<RecordKind>,
}Expand description
The universal persisted unit.
Fields§
§key: RecordKey§kind: RecordKind§revision: Revision§parent: Option<Revision>§body: Body§meta: Meta§links: Vec<RecordKey>§ancestors: Vec<Revision>Recent revisions this record descends from, newest first, bounded by the store’s ancestor cap. Advisory: a missing or truncated list makes sync report a conflict instead of guessing. Empty on legacy records.
deleted_at: Option<i64>Tombstones only: when the delete happened, in ms since the Unix epoch.
Stamped by the store. None means collection never purges it.
deleted_blob: Option<ContentHash>Tombstones only: the blob the deleted record’s body referenced, if it had one. A tombstone’s own body is empty, so without this the hash would be lost the moment the record was deleted and blob collection could not tell a blob that is merely deleted from one nothing points at.
A tombstone pins its blob: the blob survives until the tombstone itself is collected, so a record restored from a peer, or recreated from the same content, still has its bytes (gonzalo#292).
deleted_kind: Option<RecordKind>Tombstones only: the kind of the record that was deleted.
Set when the deleted body is retained — the manifest kinds, whose
bodies name blobs out of line — so GC knows which parser to use for the
references inside, and undelete knows what kind to recreate. A
manifest’s body is the only record of which blob was which shard, so
discarding it would leave the pinned bytes unnameable (ADR 0029).
None on a tombstone whose body was discarded, and on every tombstone
written before this field existed.
Implementations§
Source§impl Record
impl Record
Sourcepub fn create(key: RecordKey, kind: RecordKind, body: Body, meta: Meta) -> Self
pub fn create(key: RecordKey, kind: RecordKind, body: Body, meta: Meta) -> Self
A record that does not exist yet: the body’s first revision, no parent
and no history. Write it with put(record, None) (gonzalo#305).
use gonzalo_core::{Body, Identity, Meta, Record, RecordKey, RecordKind, Revision};
let key = RecordKey::new("caliban", "topics", "rust");
let meta = Meta::new(Identity::new("ada"), "example");
let v0 = Record::create(key, RecordKind::Topic, Body::Inline(b"first".to_vec()), meta);
assert_eq!(v0.revision, Revision::initial(b"first"));
assert_eq!(v0.parent, None);
// The next version descends from it: `put(v1, Some(v0.revision))` commits.
let meta = Meta::new(Identity::new("ada"), "example");
let v1 = v0.update(Body::Inline(b"second".to_vec()), meta);
assert_eq!(v1.revision, v0.revision.next(b"second"));
assert_eq!(v1.parent, Some(v0.revision));Sourcepub fn update(&self, body: Body, meta: Meta) -> Self
pub fn update(&self, body: Body, meta: Meta) -> Self
The next version of this record carrying body, written by meta.
Its revision follows this one and its parent is this revision, so
put(next, Some(current.revision)) commits it and a stale read
conflicts — which is the pairing that is easy to get wrong by hand
(gonzalo#305). key, kind and links carry over.
ancestors is left empty: the store folds this record’s revision and
history in when it commits, bounded by its ancestor cap. deleted_at
is cleared, since only a store writes a tombstone.
Sourcepub fn is_tombstone(&self) -> bool
pub fn is_tombstone(&self) -> bool
Whether this record is a deletion marker.