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
//! Incremental Brotli decompression and explicit resource policies.
//!
//! One decoder owns reusable workspace; each session borrows it exclusively.
//! RAW prefixes and standard/large windows are available in every profile.
//! Serialized/custom dictionary extensions require `experimental`.
//!
//! # Examples
//!
//! A strict one-shot operation rejects trailing bytes and can reuse storage:
//! ```
//! use mbrotli::{DecoderConfig, Decompressor};
//! // An uncompressed Brotli meta-block containing "hello".
//! let compressed = [0x0b, 0x02, 0x80, b'h', b'e', b'l', b'l', b'o', 0x03];
//! let mut decoder = Decompressor::new(DecoderConfig::default())?;
//! assert_eq!(decoder.decompress(&compressed)?, b"hello");
//! assert_eq!(decoder.decompress(&compressed)?, b"hello");
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! Set explicit budgets for untrusted data. Defaults impose no numeric limits;
//! an extended header alone never allocates its declared window size:
//! ```
//! use mbrotli::{DecodeLimits, DecoderConfig, Decompressor, WindowLimit};
//! let limits = DecodeLimits::default()
//! .with_max_input_bytes(Some(1 << 20))
//! .with_max_output_bytes(Some(8 << 20))
//! .with_max_workspace_bytes(Some(32 << 20));
//! let config = DecoderConfig::default()
//! .with_window_limit(WindowLimit::standard(24)?)
//! .with_limits(limits);
//! let mut decoder = Decompressor::new(config)?;
//! assert!(decoder.decompress(&[0x3b])?.is_empty());
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! A session stops exactly at its first member, preserving protocol suffixes:
//! ```
//! use mbrotli::{DecodeOperation, DecodeStreamConfig, DecoderConfig, DecoderStatus, Decompressor};
//! let mut decoder = Decompressor::new(DecoderConfig::default())?;
//! let mut session = decoder.start(DecodeStreamConfig::default())?;
//! let progress = session.process(&[0x3b, 0xaa], &mut [], DecodeOperation::Process)?;
//! assert_eq!(progress.consumed, 1);
//! assert_eq!(progress.status, DecoderStatus::Finished);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
/// Experimental structured container decoding.