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
67
68
69
70
71
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Unpublished format-rendering outcomes consumed by the transaction runtime.
use crate::RedactionCompletion;
use crate::RedactionReasons;
/// Carries rendered text and degradation provenance without constructing a
/// publishable output or transaction summary inside a format adapter.
pub(crate) struct RenderedOperation {
/// Log-safe unpublished text produced by one adapter.
text: String,
/// Completion state produced by bounded rendering.
completion: RedactionCompletion,
/// Machine-readable degradation provenance.
reasons: RedactionReasons,
}
impl RenderedOperation {
/// Creates an unpublished operation from the runtime sink's final state.
#[must_use]
pub(super) const fn from_parts(text: String, completion: RedactionCompletion, reasons: RedactionReasons) -> Self {
Self {
text,
completion,
reasons,
}
}
/// Borrows the unpublished rendered text.
#[must_use]
pub(crate) fn text(&self) -> &str {
&self.text
}
/// Returns the renderer's completion state.
#[must_use]
pub(crate) const fn completion(&self) -> RedactionCompletion {
self.completion
}
/// Returns the renderer's accumulated provenance.
#[must_use]
pub(crate) const fn reasons(&self) -> RedactionReasons {
self.reasons
}
/// Combines two independently rendered parts into one unpublished result.
#[must_use]
pub(crate) fn merge(mut self, other: Self) -> Self {
self.text.push_str(other.text());
self.completion = match (self.completion, other.completion()) {
(RedactionCompletion::Exhausted, _) | (_, RedactionCompletion::Exhausted) => RedactionCompletion::Exhausted,
(RedactionCompletion::Truncated, _) | (_, RedactionCompletion::Truncated) => RedactionCompletion::Truncated,
_ => RedactionCompletion::Complete,
};
self.reasons = self.reasons.union(other.reasons());
self
}
/// Consumes this unpublished outcome into its runtime-owned parts.
#[must_use]
pub(crate) fn into_parts(self) -> (String, RedactionCompletion, RedactionReasons) {
(self.text, self.completion, self.reasons)
}
}