chio_kernel/
revocation_runtime.rs1use std::collections::HashSet;
2
3use crate::RevocationStoreError;
4
5pub trait RevocationStore: Send {
10 fn is_revoked(&self, capability_id: &str) -> Result<bool, RevocationStoreError>;
12
13 fn revoke(&mut self, capability_id: &str) -> Result<bool, RevocationStoreError>;
15}
16
17#[derive(Debug, Default)]
19pub struct InMemoryRevocationStore {
20 revoked: HashSet<String>,
21}
22
23impl InMemoryRevocationStore {
24 pub fn new() -> Self {
26 Self::default()
27 }
28}
29
30impl RevocationStore for InMemoryRevocationStore {
31 fn is_revoked(&self, capability_id: &str) -> Result<bool, RevocationStoreError> {
32 Ok(self.revoked.contains(capability_id))
33 }
34
35 fn revoke(&mut self, capability_id: &str) -> Result<bool, RevocationStoreError> {
36 Ok(self.revoked.insert(capability_id.to_owned()))
37 }
38}