27 lines
1.3 KiB
Rust
27 lines
1.3 KiB
Rust
//! Caps of the decode child (review Part IV.1 and STEP8_FILES_ANALYSIS II.5 step 6).
|
||
|
||
use std::time::Duration;
|
||
|
||
/// Largest accepted upload (STEP8 D4: 5 MiB at upload).
|
||
pub const MAX_INPUT_BYTES: usize = 5 * 1024 * 1024;
|
||
/// Largest output the parent reads before killing the child (a 512 × 512 WebP is ~30 KB).
|
||
pub const MAX_OUTPUT_BYTES: usize = 512 * 1024;
|
||
/// Smallest accepted side of the source image.
|
||
pub const MIN_SIDE: u32 = 64;
|
||
/// Largest accepted side of the source image (header check before decoding).
|
||
pub const MAX_SIDE: u32 = 4096;
|
||
/// Allocation budget handed to the decoders (`image::Limits::max_alloc`, advisory).
|
||
pub const MAX_ALLOC_BYTES: u64 = 256 * 1024 * 1024;
|
||
/// Side of the produced avatar.
|
||
pub const OUTPUT_SIDE: u32 = 512;
|
||
/// Lossy WebP quality of the produced avatar.
|
||
pub const WEBP_QUALITY: f32 = 82.0;
|
||
/// Hard address-space cap of the child (`RLIMIT_AS`): the real memory bound.
|
||
pub const CHILD_ADDRESS_SPACE_BYTES: u64 = 512 * 1024 * 1024;
|
||
/// CPU-time cap of the child (`RLIMIT_CPU`, seconds).
|
||
pub const CHILD_CPU_SECONDS: u64 = 10;
|
||
/// Wall-clock deadline after which the parent kills the child.
|
||
pub const CHILD_DEADLINE: Duration = Duration::from_secs(20);
|
||
/// Oldest libwebp the worker accepts to link (D-R4: the linked version is controlled).
|
||
pub const MIN_LIBWEBP_VERSION: (u8, u8, u8) = (1, 6, 0);
|