1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
/*
* Copyright (c) 2023.
*
* This software is free software; You can redistribute it or modify it under terms of the MIT, Apache License or Zlib license
*/
//! An incredibly spiffy deflate decoder.
//!
//! This crate features a deflate/zlib decoder inspired by
//! Eric Bigger's [libdeflate].
//!
//! This libary has a smaller set of features hence you should use it
//! if it aligns with your end goals.
//!
//! Use it if
//! - You want a smaller library footprint when compared to flate/miniz-oxide
//! - You want faster speeds than zlib-ng/zlib/miniz-oxide.
//! - You do full buffer decompression and not streaming decompression.
//! - You don't need compression support for now, it will come soon enough.
//! - You want a 100% safe, pure rust implementation with above.
//!
//!Do not use it if
//! - You want compression support, not yet there
//! - You stream your data, not compatible with this library
//!
//! ## Alternatives
//!- For the fastest speeds, check out [libdeflate] (C), if using Rust there is [libdeflater] which
//! provides bindings to [libdeflate]
//!
//!- For streaming support use [flate2-rs] with an appropriate backend(zlib-ng is recommended for speed)
//!
//! # Features
//! You can disable features depending on what you need. the following are
//! features present
//! - gzip: Enable gzip decoding
//! - zlib: Enable zlib decoding
//!
//! These features are enabled by default
//!
//! To disable a feature , modify Cargo.toml to disable default features
//! and add the needed feature , e.g below will include zlib decoding and disable gzip decoding
//! ```toml
//! zune-inflate={ version="0.2",default-features=false,feature=["zlib"]}
//! ```
//!
//! # Errors
//! In case of an error, the library returns the error and the decoded
//! data up to when the error was encountered hence that data can be recovered
//! but no data further than that can be recovered
//!
//!
//! # Usage
//!
//! Decoding delfate data
//
//! ```no_run
//! use zune_inflate::DeflateDecoder;
//! let totally_valid_data = [0;23];
//! let mut decoder = DeflateDecoder::new(&totally_valid_data);
//!
//! let decompressed =decoder.decode_deflate().unwrap();
//! ```
//!
//! Decoding zlib data
//! ```no_run
//! use zune_inflate::DeflateDecoder;
//! // yea this isn't valid
//! let totally_valid_data = [0;23];
//! let mut decoder = DeflateDecoder::new(&totally_valid_data);
//!
//! let decompressed =decoder.decode_zlib().unwrap();
//! ```
//!
//! Decoding zlib data without confirming the adler32 checksum
//! ```no_run
//! use zune_inflate::DeflateDecoder;
//! use zune_inflate::DeflateOptions;
//! let totally_valid_data=[0;23];
//! let mut options = DeflateOptions::default()
//! .set_confirm_checksum(false);
//! let decoder = DeflateDecoder::new_with_options(&totally_valid_data,options);
//!
//! ```
//!
//! [libdeflate]: https://github.com/ebiggers/libdeflate
//! [libdeflater]: https://github.com/adamkewley/libdeflater
//! [flate2-rs]: https://github.com/rust-lang/flate2-rs
//!
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
pub use crate::decoder::{DeflateDecoder, DeflateOptions};
pub use crate::encoder::DeflateEncoder;
mod bitstream;
mod constants;
mod crc;
mod decoder;
mod encoder;
pub mod errors;
mod gzip_constants;
mod utils;