pub struct RedactedString(/* private fields */);Expand description
String wrapper whose Debug/Display implementations never reveal the
underlying value, and whose buffer is zeroized on drop.
Implementations§
Source§impl RedactedString
impl RedactedString
Sourcepub fn new(value: impl Into<String>) -> RedactedString
pub fn new(value: impl Into<String>) -> RedactedString
Construct from any Into<String>.
Sourcepub fn expose_secret(&self) -> &str
pub fn expose_secret(&self) -> &str
Reach through the redaction to obtain the plaintext value.
Calls to this function are the trust boundary: every caller is
responsible for not propagating the returned &str into any path that
might log it.
Sourcepub fn preview(&self) -> String
pub fn preview(&self) -> String
Redacted preview suitable for operator-facing logs: first four and
last four characters with the middle masked, e.g. "sk-a***wxyz".
Values shorter than twelve characters render as "***" so that the
preview never reveals more than half of any single secret.
Char-aware so multi-byte UTF-8 cannot be split in the middle of a code
point. Not a cryptographic identifier — do not use for authentication
or de-duplication.
Trait Implementations§
Source§impl Clone for RedactedString
impl Clone for RedactedString
Source§fn clone(&self) -> RedactedString
fn clone(&self) -> RedactedString
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RedactedString
impl Debug for RedactedString
Source§impl<'de> Deserialize<'de> for RedactedString
impl<'de> Deserialize<'de> for RedactedString
Source§fn deserialize<D>(
deserializer: D,
) -> Result<RedactedString, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<RedactedString, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for RedactedString
impl Display for RedactedString
Source§impl From<&str> for RedactedString
impl From<&str> for RedactedString
Source§fn from(value: &str) -> RedactedString
fn from(value: &str) -> RedactedString
Source§impl From<String> for RedactedString
impl From<String> for RedactedString
Source§fn from(value: String) -> RedactedString
fn from(value: String) -> RedactedString
Source§impl JsonSchema for RedactedString
impl JsonSchema for RedactedString
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for RedactedString
impl PartialEq for RedactedString
Source§impl Serialize for RedactedString
impl Serialize for RedactedString
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,
impl Eq for RedactedString
Auto Trait Implementations§
impl Freeze for RedactedString
impl RefUnwindSafe for RedactedString
impl Send for RedactedString
impl Sync for RedactedString
impl Unpin for RedactedString
impl UnsafeUnpin for RedactedString
impl UnwindSafe for RedactedString
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
fn into_option(self) -> Option<T>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.