use std::collections::HashSet;
use crate::RevocationStoreError;
pub trait RevocationStore: Send {
fn is_revoked(&self, capability_id: &str) -> Result<bool, RevocationStoreError>;
fn revoke(&mut self, capability_id: &str) -> Result<bool, RevocationStoreError>;
}
#[derive(Debug, Default)]
pub struct InMemoryRevocationStore {
revoked: HashSet<String>,
}
impl InMemoryRevocationStore {
pub fn new() -> Self {
Self::default()
}
}
impl RevocationStore for InMemoryRevocationStore {
fn is_revoked(&self, capability_id: &str) -> Result<bool, RevocationStoreError> {
Ok(self.revoked.contains(capability_id))
}
fn revoke(&mut self, capability_id: &str) -> Result<bool, RevocationStoreError> {
Ok(self.revoked.insert(capability_id.to_owned()))
}
}