Skip to main content

Crate qubit_redact

Crate qubit_redact 

Source
Expand description

§Qubit Redact

Borrowed domain redaction for logs, errors, and structured diagnostics. Choose Redactor::redact_view for lazy formatting/serialization, or Redactor::redact_text for finalized text and a completeness summary. With json, Redactor::to_json serializes a domain view directly.

use qubit_redact::Redactor;

let output = Redactor::standard().redact_field("password", "raw-secret");
assert_eq!(output.text().as_str(), "<redacted>");

§Domain and serialization capabilities

#[derive(Redact)] implements Redact. #[redact(debug)] and #[redact(display)] opt into ordinary diagnostic formatting. With serde, the derive also generates structured redaction for views. Adding #[redact(serde)] makes the source’s ordinary Serialize implementation redacted as well.

RedactScalar supports one-field scalar newtypes without implementing business Debug, Display, or Serialize. Explicit level annotations at the use site determine sensitivity. Third-party values can select #[redact(level = "secret", display)].

§Policies and execution

Views own immutable policy snapshots but borrow live source values. Every use starts a new execution and budget. RedactedText is finalized and does not run redaction again. DiagnosticRedactionBatch shares a budget across related values; RedactedTextComposer builds one ordered message.

Unmarked fields remain ordinary output. Explicit derive levels are final; runtime field rules, floors, and strict mode do not override them. Disabled policy deliberately restores source values. Generated ordinary formatting and serialization read the application default at each call; explicit views and redactors retain their captured policies.

Text completion describes diagnostic completeness under the selected policy. Ordinary logging can use output.text() directly; audit callers can inspect summaries or reject incomplete text. This library does not erase source memory or protect output that bypasses its entry points.

See the user guide for complete setup, type/attribute tables, format integrations, and budgets.

Modules§

formats
Protocol and process-format adapters layered over the common runtime.

Structs§

AllowRule
A borrowed canonical field name and the breadth of its allow rule.
DebugDisplay
Presents a borrowed fmt::Debug value through fmt::Display.
DiagnosticRedactionBatch
Accumulates independently resolvable redaction items under one budget.
DiagnosticRedactionHandle
Opaque reference to one unpublished item in a crate::DiagnosticRedactionBatch.
DiagnosticRedactionOutput
Presents batch items for diagnostics without exposing resolution errors.
FieldsBuilder
Mutable view over the base field policy.
HttpContextBuilderView
Mutable view over one HTTP field context.
HttpPolicyBuilderView
Mutable view over all HTTP context differences.
MaskingPolicy
Mask policies assigned to all supported sensitivity levels.
MaskingPolicyBuilder
Mutable construction state for a MaskingPolicy.
RedactedText
Final UTF-8 text produced by a redaction operation under its selected policy.
RedactedTextComposer
Builds one ordered, redacted text value through consuming chained calls.
RedactedView
A lazy view of a source value under one fixed redaction policy.
RedactionFloor
Immutable minimum field-protection rules.
RedactionFloorBuilder
Builder for a RedactionFloor.
RedactionInspection
Highest sensitivity found by one complete, bounded inspection.
RedactionInspectionError
An inconclusive redaction inspection.
RedactionLimits
Structural and JSON limits for one redaction operation.
RedactionLimitsBuilder
Mutable construction state for RedactionLimits.
RedactionPolicy
Immutable field classification, masking, format, and resource policy.
RedactionPolicyBuilder
Mutable construction state for an immutable RedactionPolicy.
RedactionReasons
Compact set of summary reasons.
RedactionRules
Immutable, cheap-to-clone field classification snapshot.
RedactionSummary
Machine-readable summary of one redaction operation.
RedactionTextOutput
Published policy-transformed text and completion metadata from one operation.
RedactionUsage
Measured resource use for one redaction transaction.
RedactionWriter
Restricted writer for one redaction operation.
Redactor
Applies one immutable policy snapshot to supported diagnostic values.
SensitiveFieldRule
A borrowed canonical field name and its configured sensitivity.
UriPolicyBuilderView
Mutable view over URI-specific behavior.

Enums§

FieldClassification
Explains why a field is sensitive, allowed, or unknown to a policy.
FieldMatchKind
Identifies the candidate that matched a configured field rule.
FieldNameMatching
Controls which canonical field-name candidates may match policy rules.
MaskPolicy
Strategy used to mask one sensitive field value.
PolicyError
Error returned when a redaction policy contains an invalid rule.
PolicyLocation
Policy construction context where a validation error occurred.
RedactionCompletion
Describes whether a redaction operation produced all required safe output.
RedactionReason
Reason why a policy-transformed representation is degraded.
SensitiveFieldPreset
Predefined groups of sensitive field names.
Sensitivity
Sensitivity assigned to a field or explicit value.
UnkeyedJsonValuePolicy
Controls whether unkeyed JSON scalar values are redacted or preserved.
UnknownFieldPolicy
Determines how a policy handles a field with no matching rule.

Traits§

Redact
Formats a domain object through the shared immutable redaction writer.
RedactScalar
A single scalar representation usable with an explicit redaction level.
RedactSerialize
Legacy structured-redaction hook for manually implemented container adapters. Derived domain values use the projection capability instead.

Derive Macros§

Redact
Derives the borrowing qubit_redact::Redact implementation.
RedactScalar
Derives a scalar leaf capability for a one-field value object.