use crate::key_storage::KeyId;
use crate::key_storage::KeyStorageError;
use crate::key_storage::KeyType;
use async_trait::async_trait;
use identity_verification::jose::jwk::Jwk;
use identity_verification::jose::jws::JwsAlgorithm;
use super::jwk_gen_output::JwkGenOutput;
pub type KeyStorageResult<T> = Result<T, KeyStorageError>;
#[cfg(not(feature = "send-sync-storage"))]
mod storage_sub_trait {
pub trait StorageSendSyncMaybe {}
impl<S: super::JwkStorage> StorageSendSyncMaybe for S {}
}
#[cfg(feature = "send-sync-storage")]
mod storage_sub_trait {
pub trait StorageSendSyncMaybe: Send + Sync {}
impl<S: Send + Sync + super::JwkStorage> StorageSendSyncMaybe for S {}
}
#[cfg_attr(not(feature = "send-sync-storage"), async_trait(?Send))]
#[cfg_attr(feature = "send-sync-storage", async_trait)]
pub trait JwkStorage: storage_sub_trait::StorageSendSyncMaybe {
async fn generate(&self, key_type: KeyType, alg: JwsAlgorithm) -> KeyStorageResult<JwkGenOutput>;
async fn insert(&self, jwk: Jwk) -> KeyStorageResult<KeyId>;
async fn sign(&self, key_id: &KeyId, data: &[u8], public_key: &Jwk) -> KeyStorageResult<Vec<u8>>;
async fn delete(&self, key_id: &KeyId) -> KeyStorageResult<()>;
async fn exists(&self, key_id: &KeyId) -> KeyStorageResult<bool>;
}