Skip to main content

libfw_core/
constants.rs

1//! Protocol constants shared between server and client.
2
3/// Fixed chunk size for fragmented transfers (2 MiB).
4pub const CHUNK_SIZE: u64 = 2 * 1024 * 1024;
5
6/// Constant sliding-window size for streaming (64 KiB).
7pub const STREAM_BUF_SIZE: usize = 64 * 1024;
8
9/// Maximum default concurrent connections in the WASM engine.
10pub const DEFAULT_CONCURRENCY: usize = 4;
11
12/// Default maximum retry count for a failed chunk before failing the task.
13pub const MAX_RETRIES: u32 = 3;
14
15/// Default cap for a single upload (100 GiB, configurable by the server).
16pub const DEFAULT_MAX_UPLOAD_SIZE: u64 = 100 * 1024 * 1024 * 1024;
17
18/// HTTP header advertising the compression algorithm on a body stream.
19///
20/// Value is a [`CompressionFormat`](crate::compress::CompressionFormat)
21/// name (e.g. `zrip`). Mirrored by `Content-Encoding` when applicable.
22pub const HEADER_COMPRESS: &str = "x-libfw-compress";
23
24/// HTTP header carrying JSON-encoded [`FileMeta`](crate::metadata::FileMeta)
25/// for an upload or download.
26pub const HEADER_FILE_META: &str = "x-libfw-file-meta";
27
28/// HTTP header carrying the byte offset to resume an interrupted upload.
29pub const HEADER_OFFSET: &str = "x-libfw-offset";
30
31/// HTTP header carrying the (optional) transfer version handshake.
32pub const HEADER_PROTOCOL: &str = "x-libfw-protocol";
33
34/// Protocol name used in the handshake header.
35pub const PROTOCOL_NAME: &str = "libfw";
36
37/// Protocol version used in the handshake header.
38pub const PROTOCOL_VERSION: &str = "1";