Skip to main content

DelegationTree

Struct DelegationTree 

Source
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

Source

pub fn new(max_depth: u32) -> Self

Creates a new empty delegation tree with the given maximum depth.

Source

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)
Source

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.

Source

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).

Source

pub fn depth(&self, delegate_did: &str) -> u32

Returns the depth of a delegate in the tree.

A root entity (not a delegate of anyone) has depth 0. A direct delegate of a root has depth 1, and so on.

Source

pub fn revoke( &mut self, delegation_id: &str, ) -> Result<Vec<String>, DelegationError>

Revokes a delegation and all sub-delegations (cascade revocation).

Returns the list of all revoked delegation IDs, including the original and all transitively dependent delegations.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V