pub struct Credential { /* private fields */ }Expand description
Opaque credential bytes. The inner Arc<Zeroizing<Box<[u8]>>> clones are
cheap (refcount bump) but every owning Credential zeroizes on drop.
Arc lets the engine intern identical credentials without copying;
when the last ref drops, Zeroizing<Box<[u8]>> overwrites the heap
allocation before Box::drop returns it to the allocator.
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
Build a Credential from raw bytes. The bytes are copied into a
fresh Zeroizing<Box<[u8]>> and the input slice is unchanged
(caller is responsible for zeroizing whatever it came from).
Sourcepub fn from_text(s: &str) -> Self
pub fn from_text(s: &str) -> Self
Build a Credential from a borrowed str. Same semantics as
from_bytes — bytes are copied into the zeroizing allocation.
Named from_text (not from_str) to avoid the
clippy::should_implement_trait lint and to keep the API
distinct from core::str::FromStr (which has different error
semantics — we never fail to construct a Credential).
pub fn is_empty(&self) -> bool
Sourcepub fn expose_secret(&self) -> &[u8] ⓘ
pub fn expose_secret(&self) -> &[u8] ⓘ
Expose the underlying bytes. Every call site MUST be auditable —
git grep expose_secret should surface every place credentials
leave the opaque wrapper. Treat each one as a security review item.
Returns a &[u8] rather than &str because credentials may be
non-UTF-8 (binary-encoded keys, raw private-key bytes, etc).
Sourcepub fn expose_str(&self) -> Option<&str>
pub fn expose_str(&self) -> Option<&str>
Expose the credential as a &str if it’s valid UTF-8, otherwise
None. Most production credentials ARE valid UTF-8 (provider keys,
tokens, base64) so this is the common path.
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Credential
impl Debug for Credential
Source§impl<'de> Deserialize<'de> for Credential
impl<'de> Deserialize<'de> for Credential
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for Credential
impl Display for Credential
Source§impl From<&[u8]> for Credential
impl From<&[u8]> for Credential
Source§impl From<&str> for Credential
impl From<&str> for Credential
Source§impl From<String> for Credential
impl From<String> for Credential
Source§impl Hash for Credential
impl Hash for Credential
Source§impl Ord for Credential
impl Ord for Credential
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for Credential
impl PartialEq for Credential
Source§impl PartialOrd for Credential
impl PartialOrd for Credential
Source§impl Serialize for Credential
impl Serialize for Credential
Source§fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
Serialize as a tagged JSON object so the encoding is unambiguous.
kimi-wave2 §Critical: the previous "b64:<base64>" string-prefix
scheme round-tripped a UTF-8 credential like "b64:SGVsbG8="
(a literal user-typed value) through the deserializer as if it
were base64-encoded bytes, silently corrupting it. The tagged
variant {"text":"…"} / {"b64":"…"} cannot be confused with
either form.
impl Eq for Credential
Auto Trait Implementations§
impl Freeze for Credential
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnsafeUnpin for Credential
impl UnwindSafe for Credential
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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