Skip to main content

blossom_rs/
lib.rs

1//! # blossom-rs
2//!
3//! Full-featured [Blossom](https://github.com/hzrd149/blossom) blob storage library for Rust.
4//!
5//! Content-addressed blob storage over HTTP with BIP-340 Schnorr authorization
6//! via Nostr kind:24242 events.
7//!
8//! ## Features
9//!
10//! - **Embeddable server**: mount a Blossom-compliant Axum router into your app
11//! - **Async client**: upload/download with multi-server failover and SHA256 integrity
12//! - **BIP-340 auth**: kind:24242 Nostr events for upload/download/delete authorization
13//! - **Pluggable storage**: memory (testing), filesystem, S3-compatible backends
14//! - **Database layer**: metadata persistence with SQLite/Postgres support
15//! - **Access control**: pluggable authorization (whitelist, custom policies)
16//! - **File statistics**: egress tracking with DashMap accumulator
17//! - **Trait-based**: implement `BlossomSigner` for your own identity type
18//!
19//! ## Quick Start
20//!
21//! ```rust,ignore
22//! use blossom_rs::{BlobServer, FilesystemBackend, Signer};
23//!
24//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
25//! // Generate a signer (or implement BlossomSigner for your own type)
26//! let signer = Signer::generate();
27//!
28//! // Create a server with filesystem storage
29//! let server = BlobServer::new(
30//!     FilesystemBackend::new("/tmp/blobs")?,
31//!     "http://localhost:3000",
32//! );
33//!
34//! // Mount into your Axum app
35//! let app = server.router();
36//! # Ok(())
37//! # }
38//! ```
39
40pub mod access;
41pub mod auth;
42pub mod db;
43pub mod integrity;
44pub mod labels;
45pub mod lfs;
46pub mod locks;
47pub mod media;
48pub mod nostr_events;
49pub mod otel;
50pub mod protocol;
51pub mod ratelimit;
52pub mod stats;
53pub mod storage;
54pub mod traits;
55pub mod transport;
56pub mod webhooks;
57mod xdelta3;
58
59#[cfg(feature = "server")]
60pub mod server;
61
62#[cfg(feature = "client")]
63pub mod client;
64
65// Re-exports for convenience.
66pub use access::{AccessControl, Role, RoleBasedAccess};
67pub use auth::{
68    auth_header_value, build_blossom_auth, build_blossom_auth_with_extra_tags, BlossomSigner,
69    Signer,
70};
71pub use db::{BlobDatabase, MemoryDatabase};
72pub use labels::{MediaLabeler, NoopLabeler};
73pub use lfs::{
74    compress, LfsContext, LfsFileVersion, LfsStorageStats, LfsStorageType, LfsVersionDatabase,
75    LfsVersionError, MemoryLfsVersionDatabase,
76};
77pub use locks::{LockDatabase, LockError, LockFilters, LockRecord, MemoryLockDatabase};
78pub use media::{MediaProcessor, PassthroughProcessor};
79pub use protocol::{BlobDescriptor, NostrEvent};
80pub use storage::{BlobBackend, MemoryBackend};
81pub use traits::BlobClient;
82
83#[cfg(feature = "filesystem")]
84pub use storage::FilesystemBackend;
85
86#[cfg(feature = "s3")]
87pub use storage::{S3Backend, S3Config};
88
89#[cfg(feature = "server")]
90pub use server::BlobServer;
91
92#[cfg(feature = "client")]
93pub use client::batch::{upload_batch, upload_batch_concurrent, DEFAULT_MAX_CONCURRENT};
94#[cfg(feature = "client")]
95pub use client::multi::{MultiTransportClient, Transport};
96#[cfg(feature = "client")]
97pub use client::BlossomClient;
98
99#[cfg(feature = "db-sqlite")]
100pub use db::SqliteDatabase;
101
102#[cfg(feature = "db-postgres")]
103pub use db::PostgresDatabase;