pub struct Builder {
leaves: BTreeMap<String, Cid>,
blocks: BTreeMap<Cid, Vec<u8>>,
}Expand description
A repository under construction.
Records go in, and a signature turns the result into something a stranger
can check. This builds the whole tree from every record at once. A
repository already signed is changed one record at a time through
Repository::draft instead, which lands on the same tree.
Fields§
§leaves: BTreeMap<String, Cid>§blocks: BTreeMap<Cid, Vec<u8>>Implementations§
Source§impl Builder
impl Builder
Sourcepub fn insert(
&mut self,
collection: &str,
rkey: &str,
record: &Value,
) -> Result<Cid, RepoError>
pub fn insert( &mut self, collection: &str, rkey: &str, record: &Value, ) -> Result<Cid, RepoError>
Adds one record, returning the CID that now names it.
This is where a record stops being JSON a server happens to hold and becomes a block with an identity: the CID is the sha-256 of the one canonical DAG-CBOR encoding of it, and it is the value the tree keys on and the commit ultimately signs over.
Sourcepub fn commit(
self,
did: &str,
rev: &str,
prev: Option<Cid>,
key: &SigningKey,
) -> Repository
pub fn commit( self, did: &str, rev: &str, prev: Option<Cid>, key: &SigningKey, ) -> Repository
Builds the tree, writes the commit and signs it.
rev is the caller’s, because this crate has no clock and no TID
minter; prev is the commit this replaces, which is None for a
server that does not keep a commit history.