pub struct Sensitive<T>(pub(crate) T);Expand description
A wrapper type that marks the inner value as secret. This is used to prevent accidental logging
of secrets by overriding the Debug and Display implementations to redact the value. This
redaction can be bypassed by enabling the dangerous-crypto-debug feature.
Tuple Fields§
§0: TTrait Implementations§
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for Sensitive<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Sensitive<T>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> ExposeSensitive for Sensitive<T>
impl<T> ExposeSensitive for Sensitive<T>
Source§fn expose(&self) -> &T
fn expose(&self) -> &T
Explicitly borrow the wrapped value. This exposes the secret to logging. This should be used exactly only when interacting with APIs we do not control. Each usage of expose MUST have a comment justifying why it is necessary and acknowledging that the appropriate checks have been performed.
use bitwarden_sensitive_value::{ExposeSensitive, Sensitive};
fn hash_password(password: &Sensitive<String>) -> [u8; 32] {
// EXPOSE: We need to pass the password to pbkdf2, because `pbkdf2` does not support the
// sensitive type and is an external crate. It is safe to do so because the library does
// not log data.
let exposed = password.expose();
pbkdf2(exposed.as_bytes(), b"salt", 100_000)
}Source§fn expose_owned(self) -> T
fn expose_owned(self) -> T
Consume the wrapper and return the inner value. This exposes the secret to logging.
Auto Trait Implementations§
impl<T> Freeze for Sensitive<T>where
T: Freeze,
impl<T> RefUnwindSafe for Sensitive<T>where
T: RefUnwindSafe,
impl<T> Send for Sensitive<T>where
T: Send,
impl<T> Sync for Sensitive<T>where
T: Sync,
impl<T> Unpin for Sensitive<T>where
T: Unpin,
impl<T> UnsafeUnpin for Sensitive<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Sensitive<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<> Read more