libfw_core/lib.rs
1//! Shared data structures, traits, protocol constants and streaming
2//! compression abstractions for the libfw transfer library.
3//!
4//! `libfw-core` is the foundation crate consumed by both
5//! [`libfw-server`](https://docs.rs/libfw-server) (server routing /
6//! middleware) and [`libfw-client`](https://docs.rs/libfw-client) (WASM
7//! engine + JS SDK). It contains no I/O of its own: it defines the *contracts*.
8//!
9//! # Highlights
10//!
11//! - [`TokenClaims`], [`Action`] and the [`Validator`] trait for
12//! fine-grained bearer-token authorization.
13//! - [`StorageBackend`] and [`UploadSink`] traits for pluggable storage.
14//! - [`Compressor`] / [`Decompressor`] streaming traits backed by
15//! [`zrip`] (zstd) with constant-memory guarantees.
16//! - Protocol constants: [`CHUNK_SIZE`], [`HEADER_COMPRESS`],
17//! [`HEADER_FILE_META`] and friends.
18//! - Transfer metadata ([`FileMeta`], [`TransferPlan`], [`ChunkMeta`]).
19//!
20//! # Example
21//!
22//! ```no_run
23//! use libfw_core::auth::{Action, PathValidator, Validator};
24//! use libfw_core::claims::{TokenClaims, Permission};
25//!
26//! let claims = TokenClaims {
27//! sub: "user-42".into(),
28//! exp: None,
29//! permissions: vec![Permission::Read, Permission::Write],
30//! allowed_paths: vec!["/docs/".into()],
31//! };
32//! let validator = PathValidator::new();
33//! assert!(validator.validate(&claims, "/docs/spec.pdf", Action::Read).is_ok());
34//! ```
35
36pub mod auth;
37pub mod claims;
38pub mod compress;
39pub mod constants;
40pub mod error;
41pub mod metadata;
42pub mod range;
43pub mod storage;
44
45pub use auth::{Action, AuthError, PathValidator, TokenVerifier, Validator};
46pub use claims::{Permission, TokenClaims};
47pub use compress::{CompressionFormat, Compressor, Decompressor};
48pub use constants::*;
49pub use error::{CompressError, DecompressError, StorageError};
50pub use metadata::{ChunkMeta, FileMeta, TransferPlan};
51pub use range::RangeSpec;
52pub use storage::{DirEntry, StorageBackend, UploadSink, WriteMode};