Skip to main content

RedactionStrategy

Trait RedactionStrategy 

Source
pub trait RedactionStrategy<T> {
    // Required method
    fn display(&self, value: &T, f: &mut Formatter<'_>) -> Result;

    // Provided method
    fn debug(&self, value: &T, f: &mut Formatter<'_>) -> Result { ... }
}
Expand description

A redaction strategy tells apollo-redaction how to redact values for Display and Debug.

The trait is generic over the value being redacted. If you know your redaction strategy is just going to be used for a single type, you can write:

use url::Url;
use apollo_redaction::RedactionStrategy;

#[derive(Default, Clone)]
struct UrlRedactor;
impl RedactionStrategy<Url> for UrlRedactor {
    // ...
}

§Bounds and deserialization

It’s strongly recommended that all your redaction strategies derive Default and Clone. Without Default, a redacted value cannot be deserialized with serde, making it significantly less useful.

Required Methods§

Source

fn display(&self, value: &T, f: &mut Formatter<'_>) -> Result

How to redact the value for the Display ({}) implementation.

Provided Methods§

Source

fn debug(&self, value: &T, f: &mut Formatter<'_>) -> Result

How to redact the value for the Debug ({:?}) implementation. By default, this delegates to RedactionStrategy::display.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§