[−][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: 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]
impl<T> DerefMut 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: Eq> Eq for Hidden<T>
[src]
impl<T> From<T> for Hidden<T>
[src]
impl<T: Hash> Hash for Hidden<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Ord> Ord for Hidden<T>
[src]
fn cmp(&self, other: &Hidden<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<Hidden<T>> 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> Serialize for Hidden<T>
[src]
impl<T> StructDoc for Hidden<T> where
T: StructDoc,
[src]
T: StructDoc,
fn document() -> Documentation
[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,
T: RefUnwindSafe,
impl<T> Send for Hidden<T> where
T: Send,
T: Send,
impl<T> Sync for Hidden<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Hidden<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Hidden<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T, A, P> Access<T> for P where
A: Access<T>,
P: Deref<Target = A>,
[src]
A: Access<T>,
P: Deref<Target = A>,
type Guard = <A as Access<T>>::Guard
A guard object containing the value and keeping it alive. Read more
fn load(&self) -> <P as Access<T>>::Guard
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T, A> DynAccess<T> for A where
A: Access<T>,
<A as Access<T>>::Guard: 'static,
[src]
A: Access<T>,
<A as Access<T>>::Guard: 'static,
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]
U: From<T>,
impl<T> IntoResult<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,