Skip to main content

Module document

Module document 

Source
Expand description

Document actor implementation for managing automerge documents.

Document actors are passive state machines that manage individual documents. They handle loading documents from storage, saving them when needed, and managing their lifecycle.

§Architecture

  • State machines: Actors process messages and return results
  • Sans-IO: All I/O operations are returned as tasks for the caller to execute
  • Simple lifecycle: Initialize → Load → Ready → Terminate

§Usage

// Create an actor
let actor = DocumentActor::new(document_id);

// Initialize it
let result = actor.handle_message(now, SamodToActorMessage::Initialize)?;

// Execute I/O tasks
for io_task in result.io_tasks {
    let io_result = execute_io(io_task)?;
    actor.handle_io_complete(now, io_result)?;
}

Re-exports§

pub use document_actor::DocumentActor;
pub use errors::DocumentError;

Modules§

document_actor
errors
io

Structs§

CompactionHash
The SHA-256 hash of a set of change hashes, used to uniquely identify a compacted document
DocActorResult
Result of processing a message or I/O completion.
DocumentActorId
SpawnArgs
SyncMessageStat
Statistics about a single sync message processed by the document actor.
WithDocResult
Result of a document operation that includes both the closure result and any side effects.

Enums§

SyncDirection
Direction of a sync message.