Compare commits
2 commits
main
...
feat/add-d
Author | SHA1 | Date | |
---|---|---|---|
e6e8184430 | |||
cb1fb40a04 |
2 changed files with 16 additions and 0 deletions
|
@ -698,6 +698,11 @@ impl Automerge {
|
|||
bytes
|
||||
}
|
||||
|
||||
/// Mark the document as saved
|
||||
pub fn mark_saved(&mut self) {
|
||||
self.saved = self.get_heads();
|
||||
}
|
||||
|
||||
/// Save the changes since the last call to [Self::save`]
|
||||
///
|
||||
/// The output of this will not be a compressed document format, but a series of individual
|
||||
|
|
|
@ -112,6 +112,17 @@ impl Change {
|
|||
self.stored.iter_ops()
|
||||
}
|
||||
|
||||
pub fn difference(&self) -> (u32, u32) {
|
||||
self.iter_ops()
|
||||
.map(|op| match op.action {
|
||||
1 => (1, 0),
|
||||
3 => (0, 1),
|
||||
_ => (0, 0),
|
||||
})
|
||||
.reduce(|acc, x| (acc.0 + x.0, acc.1 + x.1))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn extra_bytes(&self) -> &[u8] {
|
||||
self.stored.extra_bytes()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue