High-performance implementation of plcbundle written in Rust
at main 65 lines 2.4 kB view raw
1//! plcbundle-rs: high-performance PLC bundle access, DID resolution, and tooling 2//! 3//! This crate provides `BundleManager` and supporting types to work with PLC repositories 4//! consisting of compressed JSONL bundle files. It focuses on: 5//! - Fast random access via multi-frame compression and metadata offsets 6//! - A memory-efficient DID index for lookups across bundles and mempool 7//! - Query, export, verification, and sync utilities 8//! 9//! # Quickstart 10//! 11//! ```no_run 12//! use plcbundle::{BundleManager, ManagerOptions, QuerySpec, BundleRange, QueryMode}; 13//! use std::path::PathBuf; 14//! 15//! let mgr = BundleManager::new(PathBuf::from("/data/plc"), ManagerOptions::default())?; 16//! 17//! // Resolve a DID 18//! let resolved = mgr.resolve_did("did:plc:abcdef...")?; 19//! assert!(resolved.locations_found >= 0); 20//! 21//! // Query a bundle range 22//! let spec = QuerySpec { bundles: BundleRange::Range(1, 10), filter: None, query: String::new(), mode: QueryMode::Simple }; 23//! for item in mgr.query(spec) { let _ = item?; } 24//! # Ok::<(), anyhow::Error>(()) 25//! ``` 26//! 27//! # Features 28//! - Sync new bundles from a PLC source with deduplication and verified hashes 29//! - Export results in JSONL with optional compression 30//! - Rollback, migrate, clean, and rebuild indices 31//! 32// src/lib.rs 33pub(crate) mod bundle_format; 34pub mod constants; 35pub mod did_index; 36pub(crate) mod ffi; 37pub mod format; 38pub mod handle_resolver; 39pub mod index; 40pub(crate) mod iterators; 41mod manager; 42pub mod mempool; 43pub(crate) mod operations; 44pub(crate) mod options; 45pub mod plc_client; 46pub mod processor; 47pub mod remote; 48pub mod resolver; 49pub mod runtime; 50#[cfg(feature = "server")] 51pub mod server; 52pub mod sync; 53pub(crate) mod verification; 54 55// Re-export main types 56pub use iterators::{ExportIterator, QueryIterator, RangeIterator}; 57pub use manager::{ 58 BundleInfo, BundleManager, BundleRange, ChainVerifyResult, ChainVerifySpec, CleanPreview, 59 CleanPreviewFile, CleanResult, DIDIndexStats, ExportFormat, ExportSpec, InfoFlags, 60 IntoManagerOptions, LoadOptions, LoadResult, ManagerOptions, ManagerStats, OperationResult, 61 QuerySpec, RebuildStats, ResolveResult, RollbackFileStats, RollbackPlan, RollbackResult, 62 RollbackSpec, SyncResult, VerifyResult, VerifySpec, WarmUpSpec, WarmUpStrategy, 63}; 64pub use operations::{Operation, OperationFilter, OperationRequest, OperationWithLocation}; 65pub use options::{Options, OptionsBuilder, QueryMode};