pub struct SecretString(/* private fields */);
Expand description
A secure string type for sensitive configuration values like API keys.
This type ensures that sensitive values are not accidentally logged or displayed in debug output.
Implementations§
Source§impl SecretString
impl SecretString
Sourcepub fn new(value: impl Into<String>) -> SecretString
pub fn new(value: impl Into<String>) -> SecretString
Create a new secret string
Sourcepub fn expose_secret(&self) -> &str
pub fn expose_secret(&self) -> &str
Get the secret value
§Security Note
Be careful when using this method - the returned string can be logged or displayed if not handled properly.
Trait Implementations§
Source§impl Clone for SecretString
impl Clone for SecretString
Source§fn clone(&self) -> SecretString
fn clone(&self) -> SecretString
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SecretString
impl Debug for SecretString
Source§impl<'de> Deserialize<'de> for SecretString
impl<'de> Deserialize<'de> for SecretString
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SecretString, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SecretString, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&str> for SecretString
impl From<&str> for SecretString
Source§fn from(value: &str) -> SecretString
fn from(value: &str) -> SecretString
Converts to this type from the input type.
Source§impl From<String> for SecretString
impl From<String> for SecretString
Source§fn from(value: String) -> SecretString
fn from(value: String) -> SecretString
Converts to this type from the input type.
Source§impl Serialize for SecretString
impl Serialize for SecretString
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for SecretString
impl RefUnwindSafe for SecretString
impl Send for SecretString
impl Sync for SecretString
impl Unpin for SecretString
impl UnwindSafe for SecretString
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