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
// =============================================================================
// Copyright (c) 2025 - 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Thread-local bounded-mask formatting context.
use Cell;
use MaskByteLimitReset;
thread_local!
/// Executes `operation` while bounding each materialized mask on this thread.
///
/// A nested operation may tighten the active ceiling but cannot widen a
/// ceiling established by an outer bounded formatter.
///
/// # Type Parameters
///
/// * `T` - Result type produced by the bounded operation.
///
/// # Parameters
///
/// * `max_bytes` - Maximum bytes retained by one materialized mask.
/// * `operation` - Formatting operation executed inside the bounded context.
///
/// # Returns
///
/// The result produced by `operation` after restoring any previous context.
pub
/// Returns the active per-thread materialized-mask ceiling, when bounded.
///
/// # Returns
///
/// `Some(max_bytes)` while bounded display formatting is active, or `None`
/// for ordinary unbounded redaction.
pub