#![cfg_attr(feature = "std", doc = "```")]
#![cfg_attr(not(feature = "std"), doc = "```ignore")]
#![cfg_attr(feature = "std", doc = "```")]
#![cfg_attr(not(feature = "std"), doc = "```ignore")]
#![cfg_attr(not(feature = "std"), no_std)]
#![forbid(unsafe_code)]
#![forbid(missing_docs)]
#[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc;
#[cfg(all(feature = "alloc", feature = "std"))]
use std as alloc;
pub(crate) const MAX_CODESIZE: u8 = 12;
pub(crate) const MAX_ENTRIES: usize = 1 << MAX_CODESIZE as usize;
pub(crate) type Code = u16;
pub(crate) const STREAM_BUF_SIZE: usize = 1 << 24;
#[derive(Clone, Copy, Debug)]
pub enum BitOrder {
Msb,
Lsb,
}
#[cfg(feature = "alloc")]
pub(crate) enum StreamBuf<'d> {
Borrowed(&'d mut [u8]),
Owned(crate::alloc::vec::Vec<u8>),
}
#[cold]
fn assert_decode_size(size: u8) {
assert!(
size <= MAX_CODESIZE,
"Maximum code size 12 required, got {}",
size
);
}
#[cold]
fn assert_encode_size(size: u8) {
assert!(size >= 2, "Minimum code size 2 required, got {}", size);
assert!(
size <= MAX_CODESIZE,
"Maximum code size 12 required, got {}",
size
);
}
#[cfg(feature = "alloc")]
pub mod decode;
#[cfg(feature = "alloc")]
pub mod encode;
mod error;
#[cfg(feature = "std")]
pub use self::error::StreamResult;
pub use self::error::{BufferResult, LzwError, LzwStatus};
#[cfg(all(test, feature = "alloc"))]
mod tests {
use crate::decode::Decoder;
use crate::encode::Encoder;
#[cfg(feature = "std")]
use crate::{decode, encode};
#[test]
fn stable_send() {
fn must_be_send<T: Send + 'static>() {}
must_be_send::<Decoder>();
must_be_send::<Encoder>();
#[cfg(feature = "std")]
fn _send_and_lt<'lt, T: Send + 'lt>() {}
#[cfg(feature = "std")]
fn _all_send_writer<'d, W: std::io::Write + Send + 'd>() {
_send_and_lt::<'d, decode::IntoStream<'d, W>>();
_send_and_lt::<'d, encode::IntoStream<'d, W>>();
}
}
}