Module persistence

Module persistence 

Source
Expand description

Persistence abstraction for HIVE documents

This module provides traits for persisting HIVE mesh state across restarts. Platform implementations can use platform-specific storage backends:

  • ESP32: NVS (Non-Volatile Storage)
  • iOS/macOS: Keychain or UserDefaults
  • Android: SharedPreferences or EncryptedSharedPreferences
  • Linux: File-based or SQLite

§Usage

use hive_btle::persistence::{DocumentStore, MemoryStore};
use hive_btle::document::HiveDocument;
use hive_btle::NodeId;

// Use the in-memory store for testing
let mut store = MemoryStore::new();

// Save a document
let doc = HiveDocument::new(NodeId::new(0x12345678));
store.save(&doc).unwrap();

// Load it back
let loaded = store.load().unwrap();
assert!(loaded.is_some());

Structs§

FileStore
File-based document store
MemoryStore
In-memory document store for testing
SharedStore
Wrapper to make a DocumentStore shareable across threads

Traits§

DocumentStore
Trait for persisting HIVE documents