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
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Returns the documentation for the type. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for Hidden<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Hidden<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
The equivalent of Access::load
.