[−][src]Struct spirit::utils::Hidden
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: PartialEq> PartialEq<Hidden<T>> for Hidden<T>
[src]
impl<T: Default> Default for Hidden<T>
[src]
impl<T: Ord> Ord for Hidden<T>
[src]
fn cmp(&self, other: &Hidden<T>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<T: Clone> Clone for Hidden<T>
[src]
fn clone(&self) -> Hidden<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> From<T> for Hidden<T>
[src]
impl<T: Eq> Eq for Hidden<T>
[src]
impl<T: PartialOrd> PartialOrd<Hidden<T>> for Hidden<T>
[src]
fn partial_cmp(&self, other: &Hidden<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Hidden<T>) -> bool
[src]
fn le(&self, other: &Hidden<T>) -> bool
[src]
fn gt(&self, other: &Hidden<T>) -> bool
[src]
fn ge(&self, other: &Hidden<T>) -> bool
[src]
impl<T> DerefMut for Hidden<T>
[src]
impl<T> Deref for Hidden<T>
[src]
impl<T: Hash> Hash for Hidden<T>
[src]
fn hash<__HT: Hasher>(&self, state: &mut __HT)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> Debug for Hidden<T>
[src]
impl<T> Serialize for Hidden<T>
[src]
impl<'de, T> Deserialize<'de> for Hidden<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<T> StructDoc for Hidden<T> where
T: StructDoc,
[src]
T: StructDoc,
fn document() -> Documentation
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> IntoResult for T
[src]
fn into_result(Self) -> Result<T, Error>
[src]
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,