#![cfg_attr(not(feature = "std"), no_std)]
#![deny(unsafe_op_in_unsafe_fn)]
#![warn(missing_docs, rust_2018_idioms)]
#[macro_use]
extern crate alloc;
use alloc::string::String;
pub mod algorithms;
#[cfg(feature = "std")]
pub mod archive;
#[cfg(feature = "cli")]
pub mod cli;
pub mod core;
#[cfg(feature = "encryption")]
pub mod crypto;
#[cfg(feature = "c-api")]
pub mod ffi;
pub mod format;
#[cfg(feature = "std")]
pub mod seekable;
pub mod utils;
#[cfg(feature = "std")]
pub use archive::{
ARCHIVE_MAGIC, ARCHIVE_VERSION, ArchiveEntry, ArchiveListItem, create_archive,
create_from_paths, extract_archive, extract_to_dir, is_archive, list_archive,
};
#[cfg(feature = "std")]
pub use core::cover::{CoverParams, train_cover};
pub use core::decoder::{Decoder, DecompressOptions, decompress, decompress_with_options};
pub use core::dictionary::Dictionary;
pub use core::encoder::{CompressOptions, Encoder, compress, compress_with_dict};
#[cfg(feature = "std")]
pub use core::frame::{FrameInfo, FrameReader};
#[cfg(feature = "std")]
pub use core::stream::{StreamDecoder, StreamEncoder};
pub use format::block::{BlockHeader, BlockType};
pub use format::header::{CompressionMode, HeaderFlags, MAGIC, VERSION, ZexHeader};
#[cfg(feature = "std")]
pub use seekable::{
SEEK_MAGIC, SEEK_VERSION, SeekEntry, SeekTable, compress_seekable, compress_seekable_writer,
decompress_range, decompress_seekable, read_seek_table,
};
pub use utils::security::SecurityPolicy;
#[cfg(feature = "encryption")]
pub use crypto::EncryptionKey;
pub const ZEX_VERSION: &str = env!("CARGO_PKG_VERSION");
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid ZEX header: {0}")]
InvalidHeader(String),
#[error("unsupported ZEX version {found} (this build supports {supported})")]
UnsupportedVersion {
found: u16,
supported: u16,
},
#[error("corrupt block: {0}")]
CorruptBlock(String),
#[error("checksum mismatch: expected 0x{expected:08x}, got 0x{actual:08x}")]
ChecksumMismatch {
expected: u32,
actual: u32,
},
#[error("size mismatch: expected {expected} bytes, got {actual}")]
SizeMismatch {
expected: u64,
actual: u64,
},
#[error("compression error: {0}")]
Compression(String),
#[error("decompression error: {0}")]
Decompression(String),
#[error("dictionary error: {0}")]
Dictionary(String),
#[cfg(feature = "std")]
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("invalid parameter: {0}")]
InvalidParameter(String),
}
pub type Result<T> = ::core::result::Result<T, Error>;