#![doc = include_str!("../README.md")]
#![no_std]
#![deny(trivial_casts, trivial_numeric_casts, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(feature = "std")]
extern crate std;
#[cfg(not(feature = "rustc-dep-of-std"))]
extern crate alloc;
#[cfg(feature = "std")]
pub(crate) const VERBOSE: bool = false;
macro_rules! vprintln {
($($x:expr),*) => {
#[cfg(feature = "std")]
if crate::VERBOSE {
std::println!($($x),*);
}
}
}
mod bit_io;
mod common;
pub use common::MIN_TARGET_BLOCK_SIZE;
mod cpu_kernel;
pub mod decoding;
#[cfg(feature = "dict_builder")]
#[cfg_attr(docsrs, doc(cfg(feature = "dict_builder")))]
pub mod dictionary;
pub mod encoding;
mod histogram;
#[cfg(feature = "lsm")]
#[cfg_attr(docsrs, doc(cfg(feature = "lsm")))]
pub mod skippable;
pub(crate) mod blocks;
#[cfg(feature = "fuzz_exports")]
pub mod fse;
#[cfg(feature = "fuzz_exports")]
pub mod huff0;
#[cfg(feature = "fuzz_exports")]
pub use crate::cpu_kernel::{CpuKernel, ScalarKernel};
pub use crate::cpu_kernel::active_cpu_kernel_name;
#[cfg(not(feature = "fuzz_exports"))]
pub(crate) mod fse;
#[cfg(not(feature = "fuzz_exports"))]
pub(crate) mod huff0;
#[cfg(feature = "std")]
pub mod io_std;
#[cfg(feature = "std")]
pub use io_std as io;
#[cfg(not(feature = "std"))]
pub mod io_nostd;
#[cfg(not(feature = "std"))]
pub use io_nostd as io;
#[cfg(test)]
mod tests;
#[cfg(feature = "bench_internals")]
#[doc(hidden)]
pub mod testing {
pub use crate::bit_io::BitReaderReversed;
pub use crate::cpu_kernel::{CpuKernel, ScalarKernel};
#[inline(always)]
pub unsafe fn copy_bytes_overshooting_for_bench(
src: (*const u8, usize),
dst: (*mut u8, usize),
copy_at_least: usize,
) {
unsafe { crate::decoding::copy_bytes_overshooting_for_bench(src, dst, copy_at_least) };
}
pub const MAX_BLOCK_SIZE: u32 = crate::common::MAX_BLOCK_SIZE;
pub fn block_splitter_decision(block: &[u8], split_level: usize) -> usize {
crate::encoding::frame_compressor::block_splitter_decision_for_bench(block, split_level)
}
pub fn huf_weight_description(data: &[u8]) -> (alloc::vec::Vec<u8>, alloc::vec::Vec<u8>) {
crate::huff0::huff0_encoder::huf_weight_description_for_test(data)
}
pub fn huf_encode4x(data: &[u8]) -> alloc::vec::Vec<u8> {
crate::huff0::huff0_encoder::huf_encode4x_for_test(data)
}
pub fn collect_level22_sequences(data: &[u8]) -> alloc::vec::Vec<(usize, usize, usize)> {
crate::encoding::match_generator::collect_level22_sequences(data)
}
#[cfg(feature = "dict_builder")]
pub fn dict_roundtrip_fixture() -> (
alloc::vec::Vec<u8>,
alloc::vec::Vec<u8>,
alloc::vec::Vec<u8>,
) {
crate::dictionary::dict_roundtrip_fixture()
}
pub use crate::blocks::block::BlockType;
pub fn first_block_type(frame: &[u8]) -> BlockType {
let (_, header_size) = crate::decoding::frame::read_frame_header_with_format(frame, false)
.expect("frame header should parse");
let mut decoder = crate::decoding::block_decoder::new();
let (header, _) = decoder
.read_block_header(&frame[header_size as usize..])
.expect("block header should parse");
header.block_type
}
pub fn frame_header_info(frame: &[u8]) -> (bool, u64, u8) {
let (h, _) = crate::decoding::frame::read_frame_header_with_format(frame, false)
.expect("frame header should parse");
(
h.descriptor.single_segment_flag(),
h.frame_content_size(),
h.descriptor.frame_content_size_bytes().unwrap_or(0),
)
}
}
pub const WILDCOPY_OVERLENGTH: usize = crate::decoding::buffer_backend::WILDCOPY_OVERLENGTH;