Skip to main content

Module kv_store

Module kv_store 

Source
Expand description

Key-Value Store Module

Provides a persistent key-value store with tagging and metadata support.

§Features

  • Simple key-value storage with persistence
  • Tag-based queries
  • Metadata filtering
  • Key pattern matching
  • Serialization utilities

§Example

use selfware::kv_store::{KvStore, Entry};

// Create a new in-memory store
let mut store = KvStore::new();
store.insert("key1", "value1").unwrap();

// Create a persistent store
let mut store = KvStore::with_path("data/store.json").unwrap();
store.upsert("key2", "value2").unwrap();

// Query by tag
let entry = Entry::new("key3", "value3")
    .with_tags(vec!["important".to_string()]);
store.upsert("key3", entry).unwrap();
let important = store.by_tag("important");

// Serialize store
let store_data: HashMap<String, Entry> = store.entries()
    .map(|e| (e.key.clone(), e.clone()))
    .collect();
let json = store_data.serialize_to_json().unwrap();

Structs§

Entry
Represents a single key-value entry in the store
KvStore
A simple key-value store with persistence support
SerializedEntry
Serialization format for storing Entry data

Enums§

KvStoreError
Error types for key-value store operations

Traits§

StoreSerializer
Serialization utilities for KvStore

Type Aliases§

Result
Result type for key-value store operations