pub struct Draft {
repository: Repository,
rewritten: Rewritten,
}Expand description
A signed repository being changed, one record at a time, into its next commit.
Each change edits the tree in place with [Tree::insert] or
[Tree::remove], and Draft::commit signs the result. The repository
that comes out is the one a Builder makes from the same records under
the same revision: the same tree, the same record blocks and the same
signed commit.
Alongside it comes what the commit changed about the blocks the
repository holds, measured against the commit the draft was opened at.
That is what a firehose frame and a since diff are made of, and working
it out here costs only the blocks that moved.
Fields§
§repository: Repository§rewritten: RewrittenImplementations§
Source§impl Draft
impl Draft
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>
Puts a record at collection/rkey, replacing whatever was there,
and answers the CID that now names it.
Fails for a record the data model cannot encode, as
Builder::insert does. The draft is then left part way through a
change, and the caller drops it.
Sourcepub fn remove(&mut self, collection: &str, rkey: &str) -> Option<Cid>
pub fn remove(&mut self, collection: &str, rkey: &str) -> Option<Cid>
Takes the record at collection/rkey out, answering the CID it was
named by, or None if the key held nothing.
Sourcepub fn commit(
self,
rev: &str,
prev: Option<Cid>,
key: &SigningKey,
) -> (Repository, Rewritten)
pub fn commit( self, rev: &str, prev: Option<Cid>, key: &SigningKey, ) -> (Repository, Rewritten)
Signs the draft as the commit at rev following prev.
Answers the repository and the blocks it holds now and did not at the commit the draft was opened at, and the reverse. The commit blocks are among them: the new one is created and the old one removed.