post_cortex_storage/lib.rs
1// Copyright (c) 2025, 2026 Julius ML
2// Licensed under the MIT License. See LICENSE at the workspace root.
3
4//! Storage backends for post-cortex.
5//!
6//! Provides the [`Storage`] trait + the lock-free RocksDB backend
7//! ([`RealRocksDBStorage`]) and an optional SurrealDB backend
8//! ([`SurrealDBStorage`], behind the `surrealdb-backend` feature).
9//! Storage is the API of persistence — domain types come from
10//! `post-cortex-core`, vector data types from `post-cortex-embeddings`
11//! (with `default-features = false` so the ML stack is not pulled in).
12//!
13//! ```text
14//! use post_cortex_storage::{Storage, RealRocksDBStorage};
15//! ```
16
17#![forbid(unsafe_code)]
18// Storage records (StoredEntity, ExportData, etc.) are large by design —
19// they're persisted records, not transient values. Boxing them on the
20// Err path would obscure the API.
21#![allow(clippy::result_large_err)]
22// Some persisted records have many fields; refactoring into nested
23// helper types would change the on-disk serialization layout.
24#![allow(clippy::type_complexity)]
25// Construction patterns like `let mut cfg = StorageConfig::default(); cfg.x = y;`
26// are clearer than a struct literal with `..Default::default()` in the
27// large config types here.
28#![allow(clippy::field_reassign_with_default)]
29// `from_str` here pre-dates `std::str::FromStr` adoption; full FromStr
30// impls land during the Phase 9 error-typing follow-up.
31#![allow(clippy::should_implement_trait)]
32// `format!` inside a format arg is occasionally clearer than computing
33// the inner string ahead of time.
34#![allow(clippy::format_in_format_args)]
35
36pub mod error;
37pub mod export_import;
38pub mod rocksdb_storage;
39pub mod traits;
40
41pub use error::{Error as StorageError, Result as StorageResult};
42
43#[cfg(feature = "surrealdb-storage")]
44pub mod surrealdb_storage;
45
46pub use export_import::{
47 CompressionType, ExportData, ExportMetadata, ExportOptions, ExportStats, ExportType,
48 ExportedSession, ExportedWorkspace, ImportOptions, ImportResult, list_export_sessions,
49 preview_export_file, read_export_file, write_export_file,
50};
51pub use rocksdb_storage::{RealRocksDBStorage, SessionCheckpoint};
52pub use traits::{
53 GraphStorage, Storage, StorageBackend, StorageBackendType, StorageConfig, VectorStorage,
54};
55
56#[cfg(feature = "surrealdb-storage")]
57pub use surrealdb_storage::SurrealDBStorage;
58#[cfg(feature = "surrealdb-storage")]
59pub use traits::SurrealDBConfig;