preflate_rs/
lib.rs

1/*---------------------------------------------------------------------------------------------
2 *  Copyright (c) Microsoft Corporation. All rights reserved.
3 *  Licensed under the Apache License, Version 2.0. See LICENSE.txt in the project root for license information.
4 *  This software incorporates material from third parties. See NOTICE.txt for details.
5 *--------------------------------------------------------------------------------------------*/
6
7// forbid lints that we already have eliminated from the codebase so they don't show up in the future
8#![forbid(unsafe_code)]
9#![forbid(trivial_casts)]
10#![forbid(trivial_numeric_casts)]
11#![forbid(non_ascii_idents)]
12#![forbid(unused_extern_crates)]
13#![forbid(unused_import_braces)]
14#![forbid(redundant_lifetimes)]
15#![forbid(single_use_lifetimes)]
16#![forbid(unused_crate_dependencies)]
17#![forbid(unused_extern_crates)]
18#![forbid(unused_lifetimes)]
19#![forbid(unused_macro_rules)]
20#![forbid(macro_use_extern_crate)]
21#![forbid(missing_unsafe_on_extern)]
22
23mod bit_helper;
24mod cabac_codec;
25mod container_processor;
26mod deflate;
27mod estimator;
28mod hash_algorithm;
29mod hash_chain;
30mod hash_chain_holder;
31mod idat_parse;
32mod preflate_error;
33mod preflate_input;
34mod scan_deflate;
35mod scoped_read;
36mod statistical_codec;
37mod stream_processor;
38mod token_predictor;
39mod tree_predictor;
40mod zstd_compression;
41
42mod utils;
43
44pub use stream_processor::{
45    PreflateStreamChunkResult, PreflateStreamProcessor, RecreateStreamProcessor,
46    preflate_whole_deflate_stream, recreate_whole_deflate_stream,
47};
48
49pub use zstd_compression::{
50    zstd_preflate_whole_deflate_stream, zstd_recreate_whole_deflate_stream,
51};
52
53pub use preflate_error::ExitCode;
54pub use preflate_error::{PreflateError, Result};
55
56pub use container_processor::{PreflateConfig, PreflateStats};
57pub use container_processor::{
58    PreflateContainerProcessor, ProcessBuffer, RecreateContainerProcessor,
59    preflate_whole_into_container, recreate_whole_from_container,
60};
61
62pub use zstd_compression::{ZstdCompressContext, ZstdDecompressContext};
63
64#[cfg(test)]
65static INIT: std::sync::Once = std::sync::Once::new();
66
67/// Initialize the logger for tests. This is a no-op if the logger is already initialized.
68#[cfg(test)]
69pub fn init_logging() {
70    INIT.call_once(|| {
71        let _ = env_logger::builder().is_test(true).try_init();
72    });
73}