Skip to main content

Crate libfw_core

Crate libfw_core 

Source
Expand description

Shared data structures, traits, protocol constants and streaming compression abstractions for the libfw transfer library.

libfw-core is the foundation crate consumed by both libfw-server (server routing / middleware) and libfw-client (WASM engine + JS SDK). It contains no I/O of its own: it defines the contracts.

§Highlights

§Example

use libfw_core::auth::{Action, PathValidator, Validator};
use libfw_core::claims::{TokenClaims, Permission};

let claims = TokenClaims {
    sub: "user-42".into(),
    exp: None,
    permissions: vec![Permission::Read, Permission::Write],
    allowed_paths: vec!["/docs/".into()],
};
let validator = PathValidator::new();
assert!(validator.validate(&claims, "/docs/spec.pdf", Action::Read).is_ok());

Re-exports§

pub use auth::Action;
pub use auth::AuthError;
pub use auth::PathValidator;
pub use auth::TokenVerifier;
pub use auth::Validator;
pub use claims::Permission;
pub use claims::TokenClaims;
pub use compress::CompressionFormat;
pub use compress::Compressor;
pub use compress::Decompressor;
pub use error::CompressError;
pub use error::DecompressError;
pub use error::StorageError;
pub use metadata::ChunkMeta;
pub use metadata::FileMeta;
pub use metadata::TransferPlan;
pub use range::RangeSpec;
pub use storage::DirEntry;
pub use storage::StorageBackend;
pub use storage::UploadSink;
pub use storage::WriteMode;
pub use ws::Block;
pub use ws::BlockSet;
pub use ws::CompleteMessage;
pub use ws::ErrorMessage;
pub use ws::Hello;
pub use ws::ReadyReply;
pub use ws::StartRequest;
pub use ws::TransferKind;
pub use ws::block_bounds;
pub use ws::block_count;
pub use ws::block_frame;
pub use ws::block_offset;
pub use ws::control_frame;
pub use ws::crc32;
pub use ws::frame_payload;
pub use ws::frame_type;
pub use ws::missing_blocks;
pub use ws::nak_frame;
pub use ws::parse_block;
pub use ws::parse_control;
pub use ws::parse_nak;
pub use ws::parse_req;
pub use ws::req_frame;
pub use ws::wave_done_frame;
pub use ws::FRAME_BLOCK;
pub use ws::FRAME_COMPLETE;
pub use ws::FRAME_ERROR;
pub use ws::FRAME_HELLO;
pub use ws::FRAME_HELLO_OK;
pub use ws::FRAME_LIST_REPLY;
pub use ws::FRAME_LIST_REQ;
pub use ws::FRAME_META_REPLY;
pub use ws::FRAME_META_REQ;
pub use ws::FRAME_NAK;
pub use ws::FRAME_READY;
pub use ws::FRAME_REQ;
pub use ws::FRAME_START;
pub use ws::FRAME_WAVE_DONE;
pub use constants::*;

Modules§

auth
Authorization contracts: actions, validator trait and path rules.
claims
Bearer-token claims and permissions.
compress
Streaming compression abstractions backed by zrip (zstd).
constants
Protocol constants shared between server and client.
error
Error types for the libfw core contracts.
metadata
Transfer metadata: file info, chunk plans and ETags.
range
Byte-range representation shared by server and client.
storage
Storage abstraction for libfw-server.
ws
WebSocket transport protocol shared by the server and the browser client.