foxstash-core 0.5.0

High-performance local RAG library - SIMD-accelerated vector search, HNSW indexing
Documentation
//! Storage layer with compression and persistence
//!
//! This module provides efficient storage capabilities for the Foxstash system,
//! including multiple compression codecs and persistence mechanisms.
//!
//! # Storage Types
//!
//! - [`FileStorage`]: Simple file-based persistence with compression
//! - [`IncrementalStorage`]: WAL-based incremental persistence for efficient updates
//!
//! # Incremental Storage
//!
//! For large indexes with frequent updates, use `IncrementalStorage` to avoid
//! rewriting the entire index on each change:
//!
//! ```no_run
//! use foxstash_core::storage::incremental::{IncrementalStorage, IncrementalConfig, IndexMetadata};
//! use foxstash_core::Document;
//!
//! fn main() -> Result<(), foxstash_core::RagError> {
//!     let config = IncrementalConfig::default()
//!         .with_checkpoint_threshold(10_000);
//!
//!     let mut storage = IncrementalStorage::new("/tmp/index", config)?;
//!
//!     // Log changes to WAL (fast append-only)
//!     let document = Document {
//!         id: "doc1".into(),
//!         content: "Hello".into(),
//!         embedding: vec![0.1; 128],
//!         metadata: None,
//!     };
//!     storage.log_add(&document)?;
//!
//!     // Periodic checkpoint (full snapshot)
//!     let index_data: Vec<String> = vec!["doc1".into()];
//!     let metadata = IndexMetadata {
//!         document_count: 1,
//!         embedding_dim: 128,
//!         index_type: "hnsw".into(),
//!     };
//!     if storage.needs_checkpoint() {
//!         storage.checkpoint(&index_data, metadata)?;
//!     }
//!     Ok(())
//! }
//! ```

pub mod compression;

#[cfg(not(target_arch = "wasm32"))]
pub mod file;

#[cfg(not(target_arch = "wasm32"))]
pub mod incremental;

pub use compression::{best_codec, compress, compress_with, decompress, Codec, CompressionStats};

#[cfg(not(target_arch = "wasm32"))]
pub use file::FileStorage;

#[cfg(not(target_arch = "wasm32"))]
pub use incremental::{
    CheckpointMeta, IncrementalConfig, IncrementalStorage, IndexMetadata, Manifest, RecoveryHelper,
    StorageStats, WalEntry, WalOperation,
};