pub struct RedactionWriter<'session> { /* private fields */ }Expand description
Restricted writer for one redaction operation.
Implementations use structural scopes to classify every field explicitly. The writer borrows one transaction and never publishes intermediate text.
§Type Parameters
'session: Exclusive borrow of the transaction receiving this value.
§Examples
use qubit_redact::{Redact, RedactionWriter, Redactor, Sensitivity};
struct Credential(&'static str);
impl Redact for Credential {
fn write_redacted(&self, writer: &mut RedactionWriter<'_>) {
writer.record("Credential", |fields| {
fields.sensitive_at_least(Sensitivity::Secret, "token", || self.0);
});
}
}
let output = Redactor::standard().redact_text(&Credential("raw-token"));
assert!(!output.text().as_str().contains("raw-token"));use qubit_redact::{Redact, RedactionWriter};
struct Value;
impl Redact for Value {
fn write_redacted(&self, writer: &mut RedactionWriter<'_>) {
let _ = writer.redact_json_text("{\"token\":\"secret\"}");
}
}Implementations§
Source§impl<'session> RedactionWriter<'session>
impl<'session> RedactionWriter<'session>
Sourcepub fn literal(&mut self, text: &'static str)
pub fn literal(&mut self, text: &'static str)
Writes a trusted static structural literal.
§Parameters
text: Trusted static structure; omitted after the frame closes.
Sourcepub fn unredacted<T>(&mut self, value: &T) -> &mut Self
pub fn unredacted<T>(&mut self, value: &T) -> &mut Self
Writes explicitly trusted dynamic content without redaction.
§Warning
This method is an explicit trust-boundary bypass: it never consults field policy, even when the active policy is strict. It is only for content that the caller has independently established as safe to expose. Never pass credentials, user-controlled diagnostic data, or a value whose classification depends on runtime policy; use a redaction-aware field method instead.
§Type Parameters
T: Possibly unsized value rendered withDebug.
§Parameters
value: Caller-verified safe value; formatting is skipped during inspection.
§Returns
This writer for subsequent writes.
Sourcepub fn unmarked<T>(&mut self, value: &T) -> &mut Self
pub fn unmarked<T>(&mut self, value: &T) -> &mut Self
Writes a field without applying redaction policy.
§Warning
This is the semantic alias used for an intentionally unmarked field and
has the same trust-boundary requirements as Self::unredacted.
§Type Parameters
T: Possibly unsized value rendered withDebug.
§Parameters
value: Caller-verified safe value with no policy classification.
§Returns
This writer for subsequent writes.
Sourcepub fn record<F>(&mut self, name: &'static str, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
pub fn record<F>(&mut self, name: &'static str, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
Sourcepub fn tuple<F>(&mut self, name: &'static str, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
pub fn tuple<F>(&mut self, name: &'static str, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
Sourcepub fn transparent<F>(&mut self, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
pub fn transparent<F>(&mut self, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
Writes exactly one field without a nominal record or tuple wrapper.
This is intended for transparent domain newtypes. The configured field still passes through the ordinary classified field operations and the same admission limits as a structured value.
§Type Parameters
F: Callback accepting the scope for any temporary writer borrow.
§Parameters
configure: One-shot callback that writes through the borrowed scope.