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§
Sourcefn save(&mut self, doc: &HiveDocument) -> Result<()>
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.
Sourcefn load(&self) -> Result<Option<HiveDocument>>
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.
Provided Methods§
Sourcefn has_document(&self) -> bool
fn has_document(&self) -> bool
Check if a document is stored
Implementors§
impl DocumentStore for FileStore
Available on crate feature
std only.impl DocumentStore for MemoryStore
Available on crate feature
std only.