aboutsummaryrefslogtreecommitdiffstats
path: root/src/document/sync.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/document/sync.rs')
-rw-r--r--src/document/sync.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/document/sync.rs b/src/document/sync.rs
index f45a316..29efb5d 100644
--- a/src/document/sync.rs
+++ b/src/document/sync.rs
@@ -27,6 +27,18 @@ impl Received {
pub(crate) fn carries_changes(&self) -> bool {
!self.0.changes.is_empty()
}
+
+ /// The bytes of the changes it carries, and of its bloom filters (`have`).
+ pub(crate) fn sizes(&self) -> (usize, usize) {
+ let changes = self.0.changes.iter().map(<[u8]>::len).sum();
+ let blooms = self
+ .0
+ .have
+ .iter()
+ .map(|have| have.bloom.to_bytes().len())
+ .sum();
+ (changes, blooms)
+ }
}
/// `payload` decoded. Before taking the document's lock: decoding a large message takes