Skip to main content

InMemoryBudgetRegistry

Struct InMemoryBudgetRegistry 

Source
pub struct InMemoryBudgetRegistry { /* private fields */ }
Expand description

Pure in-memory BudgetRegistry backed by a BTreeMap.

This implementation is no_std friendly: it keeps a deterministic map keyed by parent capability id and never reaches for clocks, locks, or allocators outside alloc. Hosted callers that need shared mutable access across threads should wrap it in their own Mutex / RwLock.

Implementations§

Source§

impl InMemoryBudgetRegistry

Source

pub fn new() -> Self

Build an empty registry.

Source

pub fn split(&self, parent_token_id: &str) -> Option<&BudgetSplit>

Borrow the live split for parent_token_id, if any. Useful for tests and operator dashboards that want to inspect headroom.

Trait Implementations§

Source§

impl BudgetRegistry for InMemoryBudgetRegistry

Source§

fn register_parent( &mut self, parent_token_id: String, parent_share_bps: u16, ) -> Result<(), BudgetSplitError>

Register a parent token’s share so subsequent delegations can be admitted against it. Re-registering the same parent with the same share is idempotent. Re-registering with a different share is a hard failure: the caller probably fed two distinct tokens with the same id, which is a delegation-graph bug.
Source§

fn try_admit_child( &mut self, parent_token_id: &str, child_token_id: String, share_bps: u16, ) -> Result<(), BudgetSplitError>

Try to admit a child token under the given parent. Read more
Source§

fn verify_child_admission( &mut self, parent_token_id: &str, child_token_id: String, share_bps: u16, ) -> Result<(), BudgetSplitError>

Check whether a child token would admit under the given parent WITHOUT acquiring a holder lease. Read more
Source§

fn release_child( &mut self, parent_token_id: &str, child_token_id: &str, expected_share_bps: u16, ) -> Result<(), BudgetSplitError>

Release a previously admitted child token under the given parent. Read more
Source§

fn evict_parent(&mut self, parent_token_id: &str)

Drop the parent’s split from the registry. Idempotent; calling evict_parent on an unregistered parent is a no-op so revocation races do not abort verification.
Source§

impl Clone for InMemoryBudgetRegistry

Source§

fn clone(&self) -> InMemoryBudgetRegistry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InMemoryBudgetRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InMemoryBudgetRegistry

Source§

fn default() -> InMemoryBudgetRegistry

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.