Skip to main content

zrip_core/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(unsafe_op_in_unsafe_fn)]
3#![cfg_attr(feature = "nightly", feature(optimize_attribute))]
4#![cfg_attr(feature = "paranoid", forbid(unsafe_code))]
5
6#[cfg(feature = "alloc")]
7extern crate alloc;
8
9#[cfg(not(feature = "paranoid"))]
10macro_rules! paranoid_unsafe_call {
11    ($e:expr) => {
12        unsafe { $e }
13    };
14}
15
16#[cfg(feature = "paranoid")]
17macro_rules! paranoid_unsafe_call {
18    ($e:expr) => {
19        $e
20    };
21}
22
23pub mod error;
24pub mod hint;
25
26pub mod bitstream;
27pub mod fse;
28pub mod hash;
29pub mod huffman;
30pub mod xxhash;
31
32pub mod block;
33pub mod frame;
34
35pub mod simd;
36
37pub mod sequence;
38pub use sequence::Sequence;
39
40#[cfg(feature = "alloc")]
41pub mod dict;
42
43pub use error::{CompressError, DecompressError, ZstdError};
44
45pub const DEFAULT_DECOMPRESS_LIMIT: usize = usize::MAX;
46
47/// A conservative output limit (128 MiB) suitable for decompressing untrusted input.
48///
49/// Use this with [`decompress_with_limit`](crate) or [`DecompressContext::decompress_with_limit`]
50/// when processing data from untrusted sources to bound memory usage.
51pub const SAFE_DECOMPRESS_LIMIT: usize = 128 * 1024 * 1024;
52
53#[doc(hidden)]
54pub const LARGE_OUTPUT_THRESHOLD: usize = 512 * 1024;