pub struct DelegationTree { /* private fields */ }Expand description
A delegation tree rooted at a human root.
Stores delegations indexed by delegate DID and by delegation ID. Max depth is configurable (default 8).
Implementations§
Source§impl DelegationTree
impl DelegationTree
Sourcepub fn new(max_depth: u32) -> Self
pub fn new(max_depth: u32) -> Self
Creates a new empty delegation tree with the given maximum depth.
Sourcepub fn add_delegation(
&mut self,
delegation: Delegation,
) -> Result<(), DelegationError>
pub fn add_delegation( &mut self, delegation: Delegation, ) -> Result<(), DelegationError>
Adds a delegation to the tree.
Validates:
- The delegation depth does not exceed max_depth
- The delegation scope is a subset of the delegator’s effective scope (no-amplification rule, §9.6)
Sourcepub fn get_delegation_chain(&self, delegate_did: &str) -> Vec<&Delegation>
pub fn get_delegation_chain(&self, delegate_did: &str) -> Vec<&Delegation>
Gets the delegation chain from a delegate up to the root.
Returns delegations in order from the immediate delegation (closest to the delegate) up to the root delegation.
Sourcepub fn effective_scope(&self, delegate_did: &str) -> Option<DelegationScope>
pub fn effective_scope(&self, delegate_did: &str) -> Option<DelegationScope>
Computes the effective scope for a delegate.
This is the intersection of all scopes in the delegation chain, implementing the intersection narrowing rule (§9.6 rule 2).
Auto Trait Implementations§
impl Freeze for DelegationTree
impl RefUnwindSafe for DelegationTree
impl Send for DelegationTree
impl Sync for DelegationTree
impl Unpin for DelegationTree
impl UnsafeUnpin for DelegationTree
impl UnwindSafe for DelegationTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more