Skip to content

Commit

Permalink
Write some doc-strings for document types
Browse files Browse the repository at this point in the history
  • Loading branch information
adzialocha committed Dec 9, 2024
1 parent ac6849e commit a43fc48
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/document.rs
Original file line number Diff line number Diff line change
@@ -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:
/// <https://automerge.org/docs/cookbook/modeling-data/#setting-up-an-initial-document-structure>
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<AutoCommit>,
Expand Down

0 comments on commit a43fc48

Please sign in to comment.