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
//! Consumer-owned retained-storage measurement contract.
use crateByteCount;
/// Reports variable storage retained by one value under an implementation's
/// documented accounting model.
///
/// An implementation must:
///
/// - exclude `size_of::<Self>()` and fixed queue-slot or envelope overhead;
/// - include transitively owned variable backing storage;
/// - charge allocated capacity, not logical length, when capacity remains
/// allocated;
/// - never undercount its documented model;
/// - be deterministic, side-effect-free, and cheap;
/// - not consult mutable interior state; and
/// - return the same charge while the value is logically unchanged.
///
/// Shared backing storage may be conservatively charged once per retaining
/// value. A type whose retained charge might not fit in `u64` should expose a
/// domain-specific fallible measurement instead of implementing this trait.
///
/// A bounded owner measures exactly once at admission and stores that charge
/// beside the admitted value. It releases the stored admission charge later;
/// it does not measure the value again during release.
///
/// Container implementations are intentionally consumer-owned.
///
/// ```compile_fail
/// use bytebudget::Retained;
/// let bytes = vec![1_u8, 2, 3];
/// let _ = bytes.retained_bytes();
/// ```
///
/// Compatibility aliases are deliberately absent.
///
/// ```compile_fail
/// use bytebudget::RetainedBytes;
/// ```