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
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Unpublished ordered text owned by the text-composition publication path.
use crate::RedactedText;
/// Accumulates unpublished aggregate text for one transaction.
pub(super) struct TextOutputBuffer {
/// Escaped redacted text retained until transaction publication.
storage: String,
}
impl TextOutputBuffer {
/// Creates an empty aggregate text buffer.
///
/// # Returns
///
/// An empty unpublished ordered output buffer.
#[must_use]
#[inline(always)]
pub(super) const fn new() -> Self {
Self { storage: String::new() }
}
/// Appends already-safe text in caller order.
///
/// # Parameters
///
/// - `text`: Already escaped and admitted text to append in caller order.
#[inline(always)]
pub(super) fn push(&mut self, text: &str) {
self.storage.push_str(text);
}
/// Consumes the buffer into its opaque published text value.
///
/// # Returns
///
/// The opaque safe text obtained by consuming the unpublished buffer.
#[must_use]
#[inline(always)]
pub(super) fn publish(self) -> RedactedText {
RedactedText::from_escaped(self.storage)
}
}