Compare commits
2 commits
main
...
feat/add-d
Author | SHA1 | Date | |
---|---|---|---|
ce5287da3e | |||
b72d749b23 |
2 changed files with 16 additions and 0 deletions
|
@ -792,6 +792,11 @@ impl Automerge {
|
||||||
bytes
|
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`]
|
/// 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
|
/// 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()
|
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] {
|
pub fn extra_bytes(&self) -> &[u8] {
|
||||||
self.stored.extra_bytes()
|
self.stored.extra_bytes()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue