Skip to main content

Module storage

Module storage 

Source
Expand description

Storage module for persisting document indices.

This module provides:

  • Workspace — An async directory-based document collection manager with LRU cache
  • Persistence — Save/load document trees and metadata with atomic writes
  • Cache — LRU cache for loaded documents
  • Lock — File locking for multi-process safety
  • Backend — Storage backend abstraction (file, memory, etc.)

§Example

use vectorless::storage::{Workspace, PersistedDocument, DocumentMeta};
use vectorless::document::DocumentTree;

// Create a workspace
let workspace = Workspace::new("./my_workspace").await?;

// Add a document
let meta = DocumentMeta::new("doc-1", "My Document", "md");
let tree = DocumentTree::new("Root", "Content");
let doc = PersistedDocument::new(meta, tree);
workspace.add(&doc).await?;

// Load it back (uses LRU cache)
let loaded = workspace.load_and_cache("doc-1").await?.unwrap();

Re-exports§

pub use backend::FileBackend;
pub use backend::MemoryBackend;
pub use backend::StorageBackend;
pub use cache::DocumentCache;
pub use codec::Codec;
pub use codec::GzipCodec;
pub use codec::IdentityCodec;
pub use codec::codec_from_config;
pub use lock::FileLock;
pub use lock::ScopedLock;
pub use migration::CURRENT_VERSION;
pub use migration::Migration;
pub use migration::MigrationContext;
pub use migration::Migrator;
pub use workspace::DocumentMetaEntry;
pub use workspace::Workspace;
pub use workspace::WorkspaceOptions;

Modules§

backend
Storage backend abstraction.
cache
Document cache with LRU eviction policy.
codec
Codec abstraction for compression and decompression.
lock
File locking for workspace safety.
migration
Version migration system for persisted data.
workspace
Async workspace management for document collections.

Structs§

DocumentMeta
Metadata for a persisted document.
PageContent
Content for a single page.
PersistedDocument
A persisted document index containing tree and metadata.
PersistenceOptions
Options for save/load operations.

Functions§

load_document
Load a document from a JSON file with checksum verification.
load_document_from_bytes
Deserialize a document from bytes.
load_document_with_options
Load a document with custom options.
load_index
Load the workspace index.
load_index_from_bytes
Deserialize an index from bytes.
load_index_with_options
Load the workspace index with custom options.
save_document
Save a document to a JSON file with atomic write and checksum.
save_document_to_bytes
Serialize a document to bytes (JSON with checksum wrapper).
save_document_with_options
Save a document with custom options.
save_index
Save the workspace index (metadata for all documents).
save_index_to_bytes
Serialize an index to bytes.
save_index_with_options
Save the workspace index with custom options.