xos_storage/lib.rs
1//! # Xorion IPFS — Decentralized Storage
2//!
3//! IPFS-backed filesystem with client-side encryption:
4//! - **IPFS client** — upload, download, pin files via the IPFS HTTP API
5//! - **AES-256-GCM encryption** — client-side encrypt/decrypt with Argon2 key derivation
6//! - **Virtual filesystem** — directory tree mapped to IPFS CIDs
7//! - **Pinning service** — track and manage pinned content
8//! - **Local cache** — LRU-style disk cache with configurable size limits
9//!
10//! ## Example
11//!
12//! ```rust
13//! use xorion_ipfs::Encryption;
14//!
15//! let enc = Encryption::from_password("secret", b"salt_at_least_8b").unwrap();
16//! let ciphertext = enc.encrypt(b"hello world").unwrap();
17//! let plaintext = enc.decrypt(&ciphertext).unwrap();
18//! assert_eq!(plaintext, b"hello world");
19//! ```
20
21pub mod cache;
22pub mod encryption;
23pub mod ipfs;
24pub mod pinning;
25pub mod vfs;
26
27/// Disk-backed LRU file cache with configurable size limits.
28pub use cache::FileCache;
29/// AES-256-GCM encryption with Argon2id key derivation.
30pub use encryption::Encryption;
31/// Async IPFS HTTP API client for add, cat, and pin operations.
32pub use ipfs::IpfsClient;
33/// Pin management service for tracking pinned IPFS content.
34pub use pinning::PinningService;
35/// Virtual filesystem that maps paths to IPFS CIDs.
36pub use vfs::VirtualFs;
37
38use thiserror::Error;
39
40#[derive(Error, Debug)]
41pub enum StorageError {
42 #[error("IPFS error: {0}")]
43 Ipfs(String),
44
45 #[error("encryption error: {0}")]
46 Encryption(String),
47
48 #[error("filesystem error: {0}")]
49 Filesystem(String),
50
51 #[error("not found: {0}")]
52 NotFound(String),
53
54 #[error("cache error: {0}")]
55 Cache(String),
56}
57
58pub type Result<T> = std::result::Result<T, StorageError>;