From a43fc484f2a6d3663e52d646886c6419d205db69 Mon Sep 17 00:00:00 2001 From: adz Date: Mon, 9 Dec 2024 23:15:42 +0100 Subject: [PATCH] Write some doc-strings for document types --- src/document.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/document.rs b/src/document.rs index 0111d6a..efe76a7 100644 --- a/src/document.rs +++ b/src/document.rs @@ -1,12 +1,22 @@ use std::fmt; use anyhow::Result; +use automerge::transaction::Transactable; use automerge::{AutoCommit, AutoSerde, Patch}; -const DOCUMENT_OBJ_ID: &str = "doc"; - +/// Hard-coded automerge document schema in bytes representation for "Aardvark". +/// +/// Creating a local document based on this schema allows peers to independently do so as they'll +/// all have the same schema and object ids in the end. Otherwise peers wouldn't be able to merge +/// their changes into each other's documents as the id's wouldn't match. +/// +/// Read more here: +/// const DOCUMENT_SCHEMA: [u8] = [1, 2, 3]; +/// Identifier in automerge document path where we store the text. +const DOCUMENT_OBJ_ID: &str = "doc"; + #[derive(Debug)] pub struct Document { doc: RefCell,