use lz77::MatchingType;
use std::convert::From;
pub const HIGH_MAX_HASH_CHECKS: u16 = 768;
pub const HIGH_LAZY_IF_LESS_THAN: u16 = 128;
#[allow(unused)]
pub const MAX_HASH_CHECKS: u16 = 32 * 1024;
pub const DEFAULT_MAX_HASH_CHECKS: u16 = 128;
pub const DEFAULT_LAZY_IF_LESS_THAN: u16 = 32;
#[derive(Clone, Copy, Debug)]
pub enum Compression {
Fast,
Default,
Best,
}
#[derive(Copy, Clone, Debug)]
pub enum SpecialOptions {
Normal,
_ForceFixed,
_ForceStored,
}
pub const DEFAULT_OPTIONS: CompressionOptions = CompressionOptions {
max_hash_checks: DEFAULT_MAX_HASH_CHECKS,
lazy_if_less_than: DEFAULT_LAZY_IF_LESS_THAN,
matching_type: MatchingType::Lazy,
special: SpecialOptions::Normal,
};
#[doc(hidden)]
pub const _HUFFMAN_ONLY: CompressionOptions = CompressionOptions {
max_hash_checks: 0,
lazy_if_less_than: 0,
matching_type: MatchingType::Greedy,
special: SpecialOptions::Normal,
};
#[derive(Copy, Clone, Debug)]
pub struct CompressionOptions {
pub max_hash_checks: u16,
pub lazy_if_less_than: u16,
pub matching_type: MatchingType,
pub special: SpecialOptions,
}
impl CompressionOptions {
pub fn high() -> CompressionOptions {
CompressionOptions {
max_hash_checks: HIGH_MAX_HASH_CHECKS,
lazy_if_less_than: HIGH_LAZY_IF_LESS_THAN,
matching_type: MatchingType::Lazy,
special: SpecialOptions::Normal,
}
}
pub fn fast() -> CompressionOptions {
CompressionOptions {
max_hash_checks: 1,
lazy_if_less_than: 0,
matching_type: MatchingType::Greedy,
special: SpecialOptions::Normal,
}
}
}
impl Default for CompressionOptions {
fn default() -> CompressionOptions {
DEFAULT_OPTIONS
}
}
impl From<Compression> for CompressionOptions {
fn from(compression: Compression) -> CompressionOptions {
match compression {
Compression::Fast => CompressionOptions::fast(),
Compression::Default => CompressionOptions::default(),
Compression::Best => CompressionOptions::high(),
}
}
}