pub trait ApiKeyStore: Send + Sync {
// Required methods
fn create_api_key<'life0, 'async_trait>(
&'life0 self,
input: CreateApiKey,
) -> Pin<Box<dyn Future<Output = AuthResult<ApiKey>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_api_key_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<ApiKey>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_api_key_by_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<ApiKey>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_api_keys_by_reference<'life0, 'life1, 'async_trait>(
&'life0 self,
reference_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Vec<ApiKey>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update_api_key<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
update: UpdateApiKey,
) -> Pin<Box<dyn Future<Output = AuthResult<ApiKey>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_api_key<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_expired_api_keys<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AuthResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn consume_api_key_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
global_rate_limit_enabled: bool,
) -> Pin<Box<dyn Future<Output = AuthResult<ConsumeApiKeyResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn consume_api_key_usage_from_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
_observed: &'life1 ApiKey,
_global_rate_limit_enabled: bool,
) -> Pin<Box<dyn Future<Output = AuthResult<ConsumeApiKeyResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Required Methods§
fn create_api_key<'life0, 'async_trait>(
&'life0 self,
input: CreateApiKey,
) -> Pin<Box<dyn Future<Output = AuthResult<ApiKey>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_api_key_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<ApiKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_api_key_by_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<ApiKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_api_keys_by_reference<'life0, 'life1, 'async_trait>(
&'life0 self,
reference_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Vec<ApiKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_api_key<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
update: UpdateApiKey,
) -> Pin<Box<dyn Future<Output = AuthResult<ApiKey>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_api_key<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_expired_api_keys<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AuthResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn consume_api_key_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
global_rate_limit_enabled: bool,
) -> Pin<Box<dyn Future<Output = AuthResult<ConsumeApiKeyResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn consume_api_key_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
global_rate_limit_enabled: bool,
) -> Pin<Box<dyn Future<Output = AuthResult<ConsumeApiKeyResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Atomically consume one use of an API key: decrement remaining (with refill), increment rate-limit counter, and update timestamps.
All counter mutations are derived from the locked row inside a transaction, preventing concurrent requests from corrupting counters. Read-only checks (enabled, expired, permissions) happen before this call in the plugin layer.
global_rate_limit_enabled: whether the plugin-level rate limiting
is turned on. Per-key settings are read from the locked row.
Provided Methods§
Sourcefn consume_api_key_usage_from_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
_observed: &'life1 ApiKey,
_global_rate_limit_enabled: bool,
) -> Pin<Box<dyn Future<Output = AuthResult<ConsumeApiKeyResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn consume_api_key_usage_from_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
_observed: &'life1 ApiKey,
_global_rate_limit_enabled: bool,
) -> Pin<Box<dyn Future<Output = AuthResult<ConsumeApiKeyResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Consume usage from the validated database snapshot with Source write phases.
Quota/refill and rate claims are independently guarded atomic writes;
successful earlier writes survive a later storage failure. Finally touch
updated_at and return the current row. This is distinct from the combined
transactional operation above and cannot be supplied by delegating to it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".