DocumentStore

Trait DocumentStore 

Source
pub trait DocumentStore: Send + Sync {
    // Required methods
    fn save(&mut self, doc: &HiveDocument) -> Result<()>;
    fn load(&self) -> Result<Option<HiveDocument>>;
    fn clear(&mut self) -> Result<()>;

    // Provided method
    fn has_document(&self) -> bool { ... }
}
Expand description

Trait for persisting HIVE documents

Implementations of this trait provide durable storage for mesh state, allowing nodes to recover their document after restarts.

§Implementation Notes

  • save() should be called after significant state changes (new peers, emergencies)
  • load() should be called during mesh initialization
  • Implementations should handle concurrent access safely
  • Consider encryption for sensitive deployment scenarios

Required Methods§

Source

fn save(&mut self, doc: &HiveDocument) -> Result<()>

Save the current document to persistent storage

This should serialize the document and write it to durable storage. Implementations should handle errors gracefully and return appropriate error types.

Source

fn load(&self) -> Result<Option<HiveDocument>>

Load a previously saved document

Returns Ok(Some(doc)) if a document was found, Ok(None) if no document exists (first run), or Err if loading failed.

Source

fn clear(&mut self) -> Result<()>

Clear any stored document

Use this for factory reset or when leaving a mesh.

Provided Methods§

Source

fn has_document(&self) -> bool

Check if a document is stored

Implementors§

Source§

impl DocumentStore for FileStore

Available on crate feature std only.
Source§

impl DocumentStore for MemoryStore

Available on crate feature std only.
Source§

impl<S: DocumentStore> DocumentStore for SharedStore<S>

Available on crate feature std only.