pub struct Sensitive<T: Zeroize>(/* private fields */);Expand description
A secret value, redacted in Debug/Display and zeroized on drop.
Never derive or implement Serialize on a type embedding this — that is
the point: Sensitive deliberately has no Serialize impl, so a
container that tries to derive one over a field of this type fails to
compile instead of silently emitting the raw secret.
Deserializing (reading a secret in from TOML/env/CLI) is fine and
supported via serde’s Deserialize — only the write-out direction is
closed.
Implementations§
Source§impl<T: Zeroize> Sensitive<T>
impl<T: Zeroize> Sensitive<T>
Sourcepub const fn expose(&self) -> &T
pub const fn expose(&self) -> &T
Returns the wrapped value. The explicit name makes every read site
grep-able (rg '\.expose\(') and visibly intentional.
The borrow this returns stays covered by Sensitive’s redaction and
zeroize-on-drop, but nothing stops a call site from cloning it out —
e.g. handing an owned String to an LLM provider client, which then
holds its own untracked, un-zeroized copy for as long as that client
lives. Closing that gap needs polyc-llm’s provider trait to accept
Sensitive directly rather than a plain String; tracked as a
follow-up, not yet done.
Sourcepub const fn expose_secret(&self) -> &T
pub const fn expose_secret(&self) -> &T
Alias for Self::expose, matching the secrecy crate’s accessor
name for call sites migrating between the two wrappers. Same
past-this-point caveat: see Self::expose.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Sensitive<T>where
T: Deserialize<'de> + Zeroize,
impl<'de, T> Deserialize<'de> for Sensitive<T>where
T: Deserialize<'de> + Zeroize,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more