Struct trust_graph::TrustGraph
source · [−]pub struct TrustGraph<S> where
S: Storage, { /* private fields */ }Expand description
Graph to efficiently calculate weights of certificates and get chains of certificates. TODO serialization/deserialization TODO export a certificate from graph
Implementations
sourceimpl<S> TrustGraph<S> where
S: Storage,
impl<S> TrustGraph<S> where
S: Storage,
pub fn new(storage: S) -> Self
sourcepub fn set_root(
&mut self,
pk: PublicKey,
max_chain_len: u32
) -> Result<(), TrustGraphError>
pub fn set_root(
&mut self,
pk: PublicKey,
max_chain_len: u32
) -> Result<(), TrustGraphError>
Insert new root weight
pub fn add_trust<T, P>(
&mut self,
trust: T,
issued_by: P,
cur_time: Duration
) -> Result<u32, TrustGraphError> where
T: Borrow<Trust>,
P: Borrow<PublicKey>,
sourcepub fn add<C>(
&mut self,
cert: C,
cur_time: Duration
) -> Result<(), TrustGraphError> where
C: Borrow<Certificate>,
pub fn add<C>(
&mut self,
cert: C,
cur_time: Duration
) -> Result<(), TrustGraphError> where
C: Borrow<Certificate>,
Certificate is a chain of trusts, add this chain to graph
sourcepub fn weight<P>(
&mut self,
pk: P,
cur_time: Duration
) -> Result<u32, TrustGraphError> where
P: Borrow<PublicKey>,
pub fn weight<P>(
&mut self,
pk: P,
cur_time: Duration
) -> Result<u32, TrustGraphError> where
P: Borrow<PublicKey>,
Get the maximum weight of trust for one public key.
sourcepub fn weight_from<P>(
&mut self,
issued_for: P,
issuer: P,
cur_time: Duration
) -> Result<u32, TrustGraphError> where
P: Borrow<PublicKey>,
pub fn weight_from<P>(
&mut self,
issued_for: P,
issuer: P,
cur_time: Duration
) -> Result<u32, TrustGraphError> where
P: Borrow<PublicKey>,
Get the maximum weight of trust for one public key.
for all chains which contain issuer
sourcepub fn certificates_weight_factor<C, I>(
&self,
certs: I
) -> Result<Option<WeightFactor>, TrustGraphError> where
C: Borrow<Certificate>,
I: IntoIterator<Item = C>,
pub fn certificates_weight_factor<C, I>(
&self,
certs: I
) -> Result<Option<WeightFactor>, TrustGraphError> where
C: Borrow<Certificate>,
I: IntoIterator<Item = C>,
Calculate weight from given certificates Returns None if there is no such public key or some trust between this key and a root key is revoked.
sourcepub fn get_all_certs_from<P>(
&mut self,
issued_for: P,
issuer: P,
cur_time: Duration
) -> Result<Vec<Certificate>, TrustGraphError> where
P: Borrow<PublicKey>,
pub fn get_all_certs_from<P>(
&mut self,
issued_for: P,
issuer: P,
cur_time: Duration
) -> Result<Vec<Certificate>, TrustGraphError> where
P: Borrow<PublicKey>,
Get all possible certificates where issued_for will be the last element of the chain,
all certificates contain issuer
and one of the destinations is the root of this chain.
sourcepub fn get_all_certs<P>(
&mut self,
issued_for: P,
cur_time: Duration
) -> Result<Vec<Certificate>, TrustGraphError> where
P: Borrow<PublicKey>,
pub fn get_all_certs<P>(
&mut self,
issued_for: P,
cur_time: Duration
) -> Result<Vec<Certificate>, TrustGraphError> where
P: Borrow<PublicKey>,
Get all possible certificates where issued_for will be the last element of the chain
and one of the destinations is the root of this chain.
sourcepub fn revoke(&mut self, revocation: Revocation) -> Result<(), TrustGraphError>
pub fn revoke(&mut self, revocation: Revocation) -> Result<(), TrustGraphError>
Mark public key as revoked.
Every chain that contains path from revoked_by to revoked pk
will be excluded from valid certificates until revocation canceled by giving trust
pub fn get_revocations<P>(
&self,
issued_for: P
) -> Result<Vec<Revocation>, TrustGraphError> where
P: Borrow<PublicKey>,
Auto Trait Implementations
impl<S> RefUnwindSafe for TrustGraph<S> where
S: RefUnwindSafe,
impl<S> Send for TrustGraph<S> where
S: Send,
impl<S> Sync for TrustGraph<S> where
S: Sync,
impl<S> Unpin for TrustGraph<S> where
S: Unpin,
impl<S> UnwindSafe for TrustGraph<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more