pub trait KeyStore: Send + Sync {
// Required methods
fn store_key<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
material: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn load_key<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, KeyStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_key<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn key_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, KeyStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_keys<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, KeyStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Trait for key storage backends
Implement this trait to integrate with external key management systems. All operations are async to support network-based backends (HSMs, cloud KMS, etc.).
§Thread Safety
Implementations must be Send + Sync to allow use across async tasks.
§Error Handling
Implementations should:
- Return
KeyStoreError::NotFoundfor missing keys (not a general error) - Return
KeyStoreError::AccessDeniedfor permission issues - Return
KeyStoreError::Unavailablefor transient failures (enable retry logic) - Return
KeyStoreError::Storagefor other backend errors
Required Methods§
Sourcefn store_key<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
material: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn store_key<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
material: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), KeyStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Store key material with the given identifier
If a key with the same ID already exists, it should be overwritten.
§Arguments
id- Unique identifier for the key (typically a DID or key ID)material- Raw key material (private key bytes)