pub struct ApiKey<Hash> { /* private fields */ }Expand description
Represents a generated API key with its hash.
The key field is stored in a SecureString which automatically zeros
its memory on drop, preventing potential memory disclosure.
Implementations§
Source§impl<T> ApiKey<T>
impl<T> ApiKey<T>
Sourcepub fn key(&self) -> &SecureString
pub fn key(&self) -> &SecureString
Returns a reference to the secure API key.
To access the underlying string, use .expose_secret() on the returned SecureString:
let key_str: &str = api_key.key().expose_secret();§Security Note
The key is stored in secure memory that is automatically zeroed on drop. Be careful NOT to clone or log the value unnecessarily.
Trait Implementations§
Auto Trait Implementations§
impl<Hash> Freeze for ApiKey<Hash>where
Hash: Freeze,
impl<Hash> RefUnwindSafe for ApiKey<Hash>where
Hash: RefUnwindSafe,
impl<Hash> Send for ApiKey<Hash>where
Hash: Send,
impl<Hash> Sync for ApiKey<Hash>where
Hash: Sync,
impl<Hash> Unpin for ApiKey<Hash>where
Hash: Unpin,
impl<Hash> UnwindSafe for ApiKey<Hash>where
Hash: 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
Mutably borrows from an owned value. Read more