pub struct ApiKeyManager { /* private fields */ }Expand description
API key manager
Implementations§
Source§impl ApiKeyManager
impl ApiKeyManager
Sourcepub fn generate_key(&self) -> (String, String)
pub fn generate_key(&self) -> (String, String)
Generate a new API key
Sourcepub fn verify_key(&self, key: &str, hash: &str) -> bool
pub fn verify_key(&self, key: &str, hash: &str) -> bool
Verify an API key against a hash
Sourcepub fn is_expired(key_hash: &ApiKeyHash) -> bool
pub fn is_expired(key_hash: &ApiKeyHash) -> bool
Check if a key is expired
Sourcepub fn is_valid(key_hash: &ApiKeyHash) -> bool
pub fn is_valid(key_hash: &ApiKeyHash) -> bool
Check if a key is valid (active and not expired)
Sourcepub fn create_hash(
&self,
key: &str,
name: String,
expires_in_days: Option<u32>,
) -> ApiKeyHash
pub fn create_hash( &self, key: &str, name: String, expires_in_days: Option<u32>, ) -> ApiKeyHash
Create an API key hash entry
Sourcepub fn revoke(&self, key_hash: &mut ApiKeyHash)
pub fn revoke(&self, key_hash: &mut ApiKeyHash)
Revoke an API key
Sourcepub fn record_usage(key_hash: &mut ApiKeyHash)
pub fn record_usage(key_hash: &mut ApiKeyHash)
Record key usage
Auto Trait Implementations§
impl Freeze for ApiKeyManager
impl RefUnwindSafe for ApiKeyManager
impl Send for ApiKeyManager
impl Sync for ApiKeyManager
impl Unpin for ApiKeyManager
impl UnwindSafe for ApiKeyManager
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