Struct spirit::utils::Hidden[][src]

#[repr(transparent)]
pub struct Hidden<T>(pub T);
Expand description

A wrapper to hide a configuration field from logs.

This acts in as much transparent way as possible towards the field inside. It only replaces the Debug and Serialize implementations with returning "******".

The idea is if the configuration contains passwords, they shouldn’t leak into the logs. Therefore, wrap them in this, eg:

use std::io::Write;
use std::str;

use spirit::utils::Hidden;

#[derive(Debug)]
struct Cfg {
    username: String,
    password: Hidden<String>,
}

let cfg = Cfg {
    username: "me".to_owned(),
    password: "secret".to_owned().into(),
};

let mut buffer: Vec<u8> = Vec::new();
write!(&mut buffer, "{:?}", cfg)?;
assert_eq!(r#"Cfg { username: "me", password: "******" }"#, str::from_utf8(&buffer)?);

Tuple Fields

0: T

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Returns the documentation for the type. Read more

Auto Trait Implementations

Blanket Implementations

A guard object containing the value and keeping it alive. Read more

The loading method. Read more

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

The equivalent of Access::load.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Turns self into the result.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.