qubit_redact/facade/diagnostic_redaction_handle.rs
1// =============================================================================
2// Copyright (c) 2026 Haixing Hu.
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6// Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Opaque capabilities for unpublished batch items.
9
10/// Opaque reference to one unpublished item in a
11/// [`crate::DiagnosticRedactionBatch`].
12///
13/// # Examples
14///
15/// ```
16/// use qubit_redact::Redactor;
17///
18/// let mut batch = Redactor::standard().diagnostic_batch();
19/// let handle = batch.redact_field("id", "42");
20/// let diagnostics = batch.finish_with_marker("<incomplete>");
21/// assert_eq!(diagnostics.text(handle).as_str(), "42");
22/// ```
23///
24/// ```compile_fail
25/// use qubit_redact::Redactor;
26///
27/// let mut batch = Redactor::strict().diagnostic_batch();
28/// let handle = batch.redact_field("password", "raw-secret");
29/// let _ = format!("{handle}");
30/// ```
31#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
32pub struct DiagnosticRedactionHandle {
33 /// Identity of the batch that created this capability.
34 pub(super) batch_id: u64,
35 /// Insertion position of the protected item within its batch.
36 pub(super) item_index: usize,
37}