trust_graph/
trust_graph_storage.rs1use crate::public_key_hashable::PublicKeyHashable as PK;
2use crate::revoke::Revocation;
3use crate::trust_graph::WeightFactor;
4use crate::trust_relation::{Auth, TrustRelation};
5use std::fmt::Display;
6use std::time::Duration;
7
8pub trait StorageError: std::error::Error + Display {}
9
10pub trait Storage {
11 type Error: StorageError + 'static;
12
13 fn get_relation(
14 &self,
15 issued_for: &PK,
16 issued_by: &PK,
17 ) -> Result<Option<TrustRelation>, Self::Error>;
18
19 fn get_authorizations(&self, issued_for: &PK) -> Result<Vec<Auth>, Self::Error>;
20 fn get_revocations(&self, issued_for: &PK) -> Result<Vec<Revocation>, Self::Error>;
21
22 fn insert(&mut self, node: TrustRelation) -> Result<(), Self::Error>;
23
24 fn get_root_weight_factor(&self, pk: &PK) -> Result<Option<WeightFactor>, Self::Error>;
25 fn set_root_weight_factor(
26 &mut self,
27 pk: PK,
28 weight_factor: WeightFactor,
29 ) -> Result<(), Self::Error>;
30 fn root_keys(&self) -> Result<Vec<PK>, Self::Error>;
31 fn revoke(&mut self, revocation: Revocation) -> Result<(), Self::Error>;
32 fn update_auth(&mut self, auth: Auth, cur_time: Duration) -> Result<(), Self::Error>;
33 fn remove_expired(&mut self, current_time: Duration) -> Result<(), Self::Error>;
34}