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
/// What a codec keeps allocated between operations.
///
/// Reuse is the point of a `Compressor`, so the default is to keep everything.
/// A caller compressing occasionally, or juggling many compressors, can trade
/// that back for memory.
///
/// # Examples
///
/// ```
/// # #[cfg(feature = "compression")]
/// # {
/// use mbrotli::{Compressor, EncoderConfig, Quality, RetentionPolicy};
///
/// let config = EncoderConfig::default().with_quality(Quality::Q5);
/// let mut encoder = Compressor::new(config)?;
/// encoder.compress(b"warm the workspace up")?;
/// assert!(encoder.retained_bytes() > 0);
///
/// encoder.trim(RetentionPolicy::ReleaseAll);
/// assert_eq!(encoder.retained_bytes(), 0);
/// # }
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```