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

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

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)?);

Trait Implementations

impl<T: Clone> Clone for Hidden<T>[src]

impl<T> Debug for Hidden<T>[src]

impl<T: Default> Default for Hidden<T>[src]

impl<T> Deref for Hidden<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for Hidden<T>[src]

impl<'de, T> Deserialize<'de> for Hidden<T> where
    T: Deserialize<'de>, 
[src]

impl<T: Eq> Eq for Hidden<T>[src]

impl<T> From<T> for Hidden<T>[src]

impl<T: Hash> Hash for Hidden<T>[src]

impl<T: Ord> Ord for Hidden<T>[src]

impl<T: PartialEq> PartialEq<Hidden<T>> for Hidden<T>[src]

impl<T: PartialOrd> PartialOrd<Hidden<T>> for Hidden<T>[src]

impl<T> Serialize for Hidden<T>[src]

impl<T> StructDoc for Hidden<T> where
    T: StructDoc
[src]

impl<T> StructuralEq for Hidden<T>[src]

impl<T> StructuralPartialEq for Hidden<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Hidden<T> where
    T: RefUnwindSafe

impl<T> Send for Hidden<T> where
    T: Send

impl<T> Sync for Hidden<T> where
    T: Sync

impl<T> Unpin for Hidden<T> where
    T: Unpin

impl<T> UnwindSafe for Hidden<T> where
    T: UnwindSafe

Blanket Implementations

impl<T, A, P> Access<T> for P where
    A: Access<T>,
    P: Deref<Target = A>, 
[src]

type Guard = <A as Access<T>>::Guard

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T, A> DynAccess<T> for A where
    A: Access<T>,
    <A as Access<T>>::Guard: 'static, 
[src]

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoResult<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.