aboutsummaryrefslogtreecommitdiffstats
path: root/src/document/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/document/mod.rs')
-rw-r--r--src/document/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/document/mod.rs b/src/document/mod.rs
index c183537..a546d63 100644
--- a/src/document/mod.rs
+++ b/src/document/mod.rs
@@ -13,6 +13,16 @@ pub(crate) use automerge::{
ScalarValue,
};
+/// How many writers (actors) `doc`'s changes have: from the changes' metadata, in
+/// time proportional to the document.
+pub(crate) fn writers(doc: &Document) -> usize {
+ doc.get_changes_meta(&[])
+ .into_iter()
+ .map(|meta| meta.actor.into_owned())
+ .collect::<std::collections::HashSet<_>>()
+ .len()
+}
+
/// The whole document as bytes, as the engine saves it: a backup, the document
/// file's full save, the size a joining node downloads.
pub(crate) fn save(doc: &Document) -> Vec<u8> {