Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

redactable/
lib.rs

1//! Type-directed redaction for structured data.
2//!
3//! This crate separates:
4//! - **Policy markers**: what kind of sensitive data this is (e.g., `Pii`, `Token`, `Email`).
5//! - **Redaction policies**: how that data should be redacted.
6//!
7//! The derive macro walks your data and applies the policy at the boundary when
8//! you call `redact()` or `Redactable::redact()`.
9//!
10//! What this crate does:
11//! - defines policy marker types (e.g., `Pii`, `Token`, `Email`)
12//! - defines redaction policies and the `redact` entrypoint
13//! - provides integrations behind feature flags (e.g. `slog`)
14//!
15//! What it does not do:
16//! - perform I/O or logging
17//! - validate your policy choices
18//!
19//! The `Sensitive` derive macro lives in `redactable-derive` and is re-exported
20//! from this crate.
21
22// <https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html>
23#![warn(
24    anonymous_parameters,
25    bare_trait_objects,
26    elided_lifetimes_in_paths,
27    missing_copy_implementations,
28    rust_2018_idioms,
29    trivial_casts,
30    trivial_numeric_casts,
31    unreachable_pub,
32    unsafe_code,
33    unused_extern_crates,
34    unused_import_braces
35)]
36// <https://rust-lang.github.io/rust-clippy/stable>
37#![warn(
38    clippy::all,
39    clippy::cargo,
40    clippy::dbg_macro,
41    clippy::float_cmp_const,
42    clippy::get_unwrap,
43    clippy::mem_forget,
44    clippy::nursery,
45    clippy::pedantic,
46    clippy::todo,
47    clippy::unwrap_used,
48    clippy::uninlined_format_args
49)]
50// Allow some clippy lints
51#![allow(
52    clippy::cargo_common_metadata,
53    clippy::missing_const_for_fn,
54    clippy::missing_errors_doc,
55    clippy::module_name_repetitions,
56    clippy::must_use_candidate,
57    clippy::use_self
58)]
59// Allow some lints while testing
60#![cfg_attr(test, allow(clippy::non_ascii_literal, clippy::unwrap_used))]
61
62pub use redactable_derive::{NotSensitive, NotSensitiveDisplay, Sensitive, SensitiveDisplay};
63
64#[allow(unused_extern_crates)]
65extern crate self as redactable;
66
67// Module declarations
68#[cfg(feature = "policy")]
69pub mod policy;
70#[cfg(feature = "redaction")]
71mod redaction;
72#[cfg(feature = "slog")]
73pub mod slog;
74#[cfg(feature = "tracing")]
75pub mod tracing;
76
77// Re-exports from policy module
78#[cfg(feature = "policy")]
79pub use policy::{
80    BlockchainAddress, CreditCard, Email, EmailConfig, IpAddress, KeepConfig, MASK_CHAR,
81    MaskConfig, PhoneNumber, Pii, REDACTED_PLACEHOLDER, RedactionPolicy, Secret,
82    TextRedactionPolicy, Token,
83};
84// Re-exports from redaction module: public API
85#[cfg(feature = "redaction")]
86pub use redaction::{
87    NotSensitive, NotSensitiveDebug, NotSensitiveDebugExt, NotSensitiveDisplay,
88    NotSensitiveDisplayExt, NotSensitiveExt, NotSensitiveValue, Redactable, RedactedOutput,
89    RedactedOutputExt, RedactedOutputRef, SensitiveValue, SensitiveWithPolicy, ToRedactedOutput,
90};
91#[cfg(feature = "json")]
92pub use redaction::{
93    NotSensitiveJson, NotSensitiveJsonExt, RedactedJson, RedactedJsonExt, RedactedJsonRef,
94};
95// Re-exports from redaction module: internal machinery (used by derive-generated code)
96#[doc(hidden)]
97#[cfg(feature = "redaction")]
98pub use redaction::PolicyRedactedFormatterRef;
99#[doc(hidden)]
100#[cfg(feature = "redaction")]
101pub use redaction::{
102    PolicyApplicable, PolicyApplicableRef, RedactableMapper, RedactableWithFormatter,
103    RedactableWithMapper, RedactedFormatterRef, ScalarRedaction, apply_policy, apply_policy_ref,
104    redact,
105};
106#[cfg(feature = "slog")]
107pub use slog::{RedactedDisplayValue, SlogRedactedDisplayExt, SlogRedactedExt};