aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
Diffstat (limited to 'src/document')
-rw-r--r--src/document/view.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/document/view.rs b/src/document/view.rs
index d8819d2..ff93ae6 100644
--- a/src/document/view.rs
+++ b/src/document/view.rs
@@ -121,11 +121,17 @@ pub(crate) fn delete_path(
/// a kind that keeps what the node reads at paths otherwise (a set of events its
/// members' entries), and hands it over so; and for what writes there through `Write`,
/// which then looks at what the tree holds after.
-#[derive(Clone, Debug, Default, PartialEq)]
+#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(not(feature = "federation"), allow(dead_code))]
pub(crate) struct Tree(pub(crate) JsonValue);
#[cfg_attr(not(feature = "federation"), allow(dead_code))]
+impl Default for Tree {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl Tree {
/// A tree holding nothing.
pub(crate) fn new() -> Self {
@@ -221,6 +227,15 @@ impl Write for Tree {
}
}
+/// Where the node reads its members: `entries`, where its document keeps them apart
+/// and hands them over as a tree (`AppState::entries`); else `doc` itself.
+pub(crate) fn members_of<'a>(entries: &'a Option<Tree>, doc: &'a dyn Read) -> &'a dyn Read {
+ match entries {
+ Some(tree) => tree,
+ None => doc,
+ }
+}
+
#[cfg(test)]
mod tree_tests {
use serde_json::json;