aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
Diffstat (limited to 'src/document')
-rw-r--r--src/document/events.rs10
-rw-r--r--src/document/inspect.rs5
2 files changed, 15 insertions, 0 deletions
diff --git a/src/document/events.rs b/src/document/events.rs
index 7b0fe5e..2b3a7e0 100644
--- a/src/document/events.rs
+++ b/src/document/events.rs
@@ -117,6 +117,16 @@ pub(crate) fn is_genesis(change: &Change, fold: &str, id: &Id) -> bool {
root.is_some_and(|root| genesis(fold, &root).hash() == change.hash())
}
+/// Puts `bytes` at the event `id`, held there or not, as no change of a node puts an
+/// event: for tests of what a change may write.
+#[cfg(test)]
+pub(crate) fn put_held(doc: &mut super::Transaction<'_>, id: &Id, bytes: &[u8]) {
+ use automerge::transaction::Transactable;
+ let events = events_map(doc).expect("the events' map");
+ doc.put(&events, id.to_string(), ScalarValue::Bytes(bytes.to_vec()))
+ .expect("a put");
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/src/document/inspect.rs b/src/document/inspect.rs
index ffdf536..350b69c 100644
--- a/src/document/inspect.rs
+++ b/src/document/inspect.rs
@@ -36,6 +36,8 @@ pub(crate) enum Action {
MakeMap,
/// Puts a string there.
PutString(String),
+ /// Puts bytes there.
+ PutBytes(Vec<u8>),
/// Deletes what is there.
Delete,
/// Changes what is there, a list or text it is in (`Place::in_list`).
@@ -198,6 +200,9 @@ impl<'a> Inspector<'a> {
OpType::Put(automerge::ScalarValue::Str(text)) => {
Action::PutString(text.to_string())
}
+ OpType::Put(automerge::ScalarValue::Bytes(bytes)) => {
+ Action::PutBytes(bytes.clone())
+ }
OpType::Delete => Action::Delete,
_ => Action::Other,
},