Skip to main content

Redacted

Struct Redacted 

Source
pub struct Redacted<T, R = SimpleRedactor> { /* private fields */ }
Expand description

A wrapper type for redacting values, so the actual values are not accidentally printed out.

A redacted value comes with a redaction strategy. The strategy provides the Display and Debug implementations for the inner type.

To access the redacted value proper, you must use the Redacted::unredact method.

Implementations§

Source§

impl<T, R: Default> Redacted<T, R>

Source

pub fn new(value: T) -> Self

Create a new redacted value with a Default redaction strategy.

use apollo_redaction::Redacted;
use apollo_redaction::strategy::SimpleRedactor;

let redacted = Redacted::<_, SimpleRedactor>::new("password for all the company's secrets");
Source§

impl<T, R> Redacted<T, R>

Source

pub fn with_strategy(value: T, strategy: R) -> Self

Create a new redacted value with a redaction strategy.

Source§

impl<T, R> Redacted<T, R>

Source

pub fn unredact(&self) -> &T

Access the underlying value.

Source

pub fn unredact_mut(&mut self) -> &mut T

Access the underlying value.

Trait Implementations§

Source§

impl<T: Clone, R: Clone> Clone for Redacted<T, R>

Source§

fn clone(&self) -> Redacted<T, R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, R: RedactionStrategy<T>> Debug for Redacted<T, R>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Default, R: Default> Default for Redacted<T, R>

Source§

fn default() -> Redacted<T, R>

Returns the “default value” for a type. Read more
Source§

impl<'de, T: Deserialize<'de>, R: Default> Deserialize<'de> for Redacted<T, R>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, R: RedactionStrategy<T>> Display for Redacted<T, R>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T, R: Default> From<T> for Redacted<T, R>

Source§

fn from(value: T) -> Self

Wrap a value in Redacted with a Default redaction strategy.

use apollo_redaction::Redacted;
use apollo_redaction::strategy::SimpleRedactor;

let redacted = Redacted::<_, SimpleRedactor>::from("password for all the company's secrets");
Source§

impl<T: FromStr, R: Default> FromStr for Redacted<T, R>

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parse a value from a string with a Default redaction strategy.

use apollo_redaction::Redacted;
use apollo_redaction::strategy::SimpleRedactor;
use url::Url;

let redacted: Redacted<Url, SimpleRedactor> = "https://apollographql.com".parse().expect("it's valid");
Source§

type Err = <T as FromStr>::Err

The associated error which can be returned from parsing.

Auto Trait Implementations§

§

impl<T, R> Freeze for Redacted<T, R>
where T: Freeze, R: Freeze,

§

impl<T, R> RefUnwindSafe for Redacted<T, R>

§

impl<T, R> Send for Redacted<T, R>
where T: Send, R: Send,

§

impl<T, R> Sync for Redacted<T, R>
where T: Sync, R: Sync,

§

impl<T, R> Unpin for Redacted<T, R>
where T: Unpin, R: Unpin,

§

impl<T, R> UnsafeUnpin for Redacted<T, R>
where T: UnsafeUnpin, R: UnsafeUnpin,

§

impl<T, R> UnwindSafe for Redacted<T, R>
where T: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.