1#![cfg_attr(not(feature = "std"), no_std)]
8#![deny(unsafe_code)]
9
10#[cfg(not(feature = "std"))]
11extern crate alloc;
12
13mod decode;
14#[cfg(feature = "std")]
15mod encode;
16
17#[cfg(feature = "parallel")]
18pub use decode::bzz_decode_parallel;
19pub use decode::{bzz_decode, decode};
20#[cfg(feature = "std")]
21pub use encode::bzz_encode;
22
23#[derive(Debug, thiserror::Error, PartialEq, Eq)]
25#[non_exhaustive]
26pub enum BzzError {
27 #[error("BZZ input is too short")]
29 TooShort,
30
31 #[error("BZZ stream contains an invalid block size")]
33 InvalidBlockSize,
34
35 #[error("BZZ stream contains an invalid BWT index")]
37 InvalidBwtIndex,
38
39 #[error("ZP coder error in BZZ stream")]
41 ZpError,
42
43 #[error("BZZ block is missing the end-of-block marker")]
45 MissingMarker,
46
47 #[error("BZZ block size exceeds maximum allowed ({0} > 4 MB)")]
49 BlockSizeTooLarge(usize),
50
51 #[error("BZZ total output size exceeds maximum allowed (256 MB)")]
53 OutputTooLarge,
54
55 #[error("BZZ stream is truncated (decoder is spinning on synthetic padding)")]
58 Truncated,
59}
60
61impl From<djvu_zp::ZpError> for BzzError {
63 fn from(_: djvu_zp::ZpError) -> Self {
64 BzzError::TooShort
65 }
66}