pub struct SecretValue(/* private fields */);Expand description
Toolkit-owned secret newtype — NEVER returns raw bytes from SecretsProvider.
Intentionally does NOT implement Debug, Display, Clone, Serialize,
Deserialize, PartialEq, Eq. Compile-fail tests at
tests/compile_fail/token_secret_no_*.rs enforce this via trybuild
(per Phase 83 review R5 + R6 + Pattern E + CMSUP-02).
Available unconditionally — does NOT depend on the code-mode feature.
When the code-mode feature is enabled, an impl From<SecretValue> for pmcp_code_mode::TokenSecret is provided for interop with the HMAC token
machinery.
The underlying bytes are zeroed on drop via secrecy::SecretBox.
Implementations§
Source§impl SecretValue
impl SecretValue
Sourcepub fn new(bytes: impl Into<Vec<u8>>) -> Self
pub fn new(bytes: impl Into<Vec<u8>>) -> Self
Create from raw bytes. The input is moved into the SecretBox without
an intermediate copy — no plaintext residue is left behind by the
constructor.
Sourcepub fn from_env(var: &str) -> Result<Self, VarError>
pub fn from_env(var: &str) -> Result<Self, VarError>
Read from an environment variable. The string value is converted to bytes and wrapped immediately.
§Errors
Returns std::env::VarError if the variable is not set or not UTF-8.
Sourcepub fn expose_secret(&self) -> &[u8] ⓘ
pub fn expose_secret(&self) -> &[u8] ⓘ
Expose the secret bytes for use by callers (HMAC, header construction, etc.). Callers MUST NOT log or persist the returned slice.
Trait Implementations§
Source§impl From<SecretValue> for TokenSecret
Available on crate feature code-mode only.Interop with pmcp_code_mode::TokenSecret when the code-mode feature is on.
impl From<SecretValue> for TokenSecret
code-mode only.Interop with pmcp_code_mode::TokenSecret when the code-mode feature is on.
Allows a SecretValue resolved by a SecretsProvider to be fed into the
HMAC token machinery in pmcp-code-mode without forcing every toolkit
consumer to depend on code-mode.
Source§fn from(v: SecretValue) -> Self
fn from(v: SecretValue) -> Self
Auto Trait Implementations§
impl Freeze for SecretValue
impl RefUnwindSafe for SecretValue
impl Send for SecretValue
impl Sync for SecretValue
impl Unpin for SecretValue
impl UnsafeUnpin for SecretValue
impl UnwindSafe for SecretValue
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> 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