Skip to main content

BudgetStore

Trait BudgetStore 

Source
pub trait BudgetStore: Send {
Show 24 methods // Required methods fn try_increment( &mut self, capability_id: &str, grant_index: usize, max_invocations: Option<u32>, ) -> Result<bool, BudgetStoreError>; fn try_charge_cost( &mut self, capability_id: &str, grant_index: usize, max_invocations: Option<u32>, cost_units: u64, max_cost_per_invocation: Option<u64>, max_total_cost_units: Option<u64>, ) -> Result<bool, BudgetStoreError>; fn reverse_charge_cost( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, ) -> Result<(), BudgetStoreError>; fn reduce_charge_cost( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, ) -> Result<(), BudgetStoreError>; fn settle_charge_cost( &mut self, capability_id: &str, grant_index: usize, exposed_cost_units: u64, realized_cost_units: u64, ) -> Result<(), BudgetStoreError>; fn list_usages( &self, limit: usize, capability_id: Option<&str>, ) -> Result<Vec<BudgetUsageRecord>, BudgetStoreError>; fn get_usage( &self, capability_id: &str, grant_index: usize, ) -> Result<Option<BudgetUsageRecord>, BudgetStoreError>; // Provided methods fn try_charge_cost_with_ids( &mut self, capability_id: &str, grant_index: usize, max_invocations: Option<u32>, cost_units: u64, max_cost_per_invocation: Option<u64>, max_total_cost_units: Option<u64>, hold_id: Option<&str>, event_id: Option<&str>, ) -> Result<bool, BudgetStoreError> { ... } fn try_charge_cost_with_ids_and_authority( &mut self, capability_id: &str, grant_index: usize, max_invocations: Option<u32>, cost_units: u64, max_cost_per_invocation: Option<u64>, max_total_cost_units: Option<u64>, hold_id: Option<&str>, event_id: Option<&str>, authority: Option<&BudgetEventAuthority>, ) -> Result<bool, BudgetStoreError> { ... } fn reverse_charge_cost_with_ids( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, ) -> Result<(), BudgetStoreError> { ... } fn reverse_charge_cost_with_ids_and_authority( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, authority: Option<&BudgetEventAuthority>, ) -> Result<(), BudgetStoreError> { ... } fn reduce_charge_cost_with_ids( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, ) -> Result<(), BudgetStoreError> { ... } fn reduce_charge_cost_with_ids_and_authority( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, authority: Option<&BudgetEventAuthority>, ) -> Result<(), BudgetStoreError> { ... } fn settle_charge_cost_with_ids( &mut self, capability_id: &str, grant_index: usize, exposed_cost_units: u64, realized_cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, ) -> Result<(), BudgetStoreError> { ... } fn settle_charge_cost_with_ids_and_authority( &mut self, capability_id: &str, grant_index: usize, exposed_cost_units: u64, realized_cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, authority: Option<&BudgetEventAuthority>, ) -> Result<(), BudgetStoreError> { ... } fn list_mutation_events( &self, _limit: usize, _capability_id: Option<&str>, _grant_index: Option<usize>, ) -> Result<Vec<BudgetMutationRecord>, BudgetStoreError> { ... } fn budget_guarantee_level(&self) -> BudgetGuaranteeLevel { ... } fn budget_authority_profile(&self) -> BudgetAuthorityProfile { ... } fn budget_metering_profile(&self) -> BudgetMeteringProfile { ... } fn authorize_budget_hold( &mut self, request: BudgetAuthorizeHoldRequest, ) -> Result<BudgetAuthorizeHoldDecision, BudgetStoreError> { ... } fn reverse_budget_hold( &mut self, request: BudgetReverseHoldRequest, ) -> Result<BudgetReverseHoldDecision, BudgetStoreError> { ... } fn release_budget_hold( &mut self, request: BudgetReleaseHoldRequest, ) -> Result<BudgetReleaseHoldDecision, BudgetStoreError> { ... } fn reconcile_budget_hold( &mut self, request: BudgetReconcileHoldRequest, ) -> Result<BudgetReconcileHoldDecision, BudgetStoreError> { ... } fn capture_budget_hold( &mut self, request: BudgetCaptureHoldRequest, ) -> Result<BudgetCaptureHoldDecision, BudgetStoreError> { ... }
}

Required Methods§

Source

fn try_increment( &mut self, capability_id: &str, grant_index: usize, max_invocations: Option<u32>, ) -> Result<bool, BudgetStoreError>

Source

fn try_charge_cost( &mut self, capability_id: &str, grant_index: usize, max_invocations: Option<u32>, cost_units: u64, max_cost_per_invocation: Option<u64>, max_total_cost_units: Option<u64>, ) -> Result<bool, BudgetStoreError>

Atomically check monetary budget limits and record provisional exposure if within bounds.

Checks:

  1. invocation_count < max_invocations (if set)
  2. cost_units <= max_cost_per_invocation (if set)
  3. (total_cost_exposed + total_cost_realized_spend + cost_units) <= max_total_cost_units (if set)

On pass: increments invocation_count by 1 and total_cost_exposed by cost_units, allocates a new replication seq, returns Ok(true). On any limit exceeded: rolls back, returns Ok(false).

Source

fn reverse_charge_cost( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, ) -> Result<(), BudgetStoreError>

Reverse a previously applied provisional exposure for a pre-execution denial path.

Source

fn reduce_charge_cost( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, ) -> Result<(), BudgetStoreError>

Release a previously exposed monetary amount without changing invocation count.

This is used when the kernel needs to release provisional exposure without realizing any spend in the budget store itself.

Source

fn settle_charge_cost( &mut self, capability_id: &str, grant_index: usize, exposed_cost_units: u64, realized_cost_units: u64, ) -> Result<(), BudgetStoreError>

Atomically release provisional exposure and record realized spend.

This removes exposed_cost_units from total_cost_exposed and adds realized_cost_units to total_cost_realized_spend without changing invocation count. realized_cost_units must not exceed exposed_cost_units.

Source

fn list_usages( &self, limit: usize, capability_id: Option<&str>, ) -> Result<Vec<BudgetUsageRecord>, BudgetStoreError>

Source

fn get_usage( &self, capability_id: &str, grant_index: usize, ) -> Result<Option<BudgetUsageRecord>, BudgetStoreError>

Provided Methods§

Source

fn try_charge_cost_with_ids( &mut self, capability_id: &str, grant_index: usize, max_invocations: Option<u32>, cost_units: u64, max_cost_per_invocation: Option<u64>, max_total_cost_units: Option<u64>, hold_id: Option<&str>, event_id: Option<&str>, ) -> Result<bool, BudgetStoreError>

Source

fn try_charge_cost_with_ids_and_authority( &mut self, capability_id: &str, grant_index: usize, max_invocations: Option<u32>, cost_units: u64, max_cost_per_invocation: Option<u64>, max_total_cost_units: Option<u64>, hold_id: Option<&str>, event_id: Option<&str>, authority: Option<&BudgetEventAuthority>, ) -> Result<bool, BudgetStoreError>

Source

fn reverse_charge_cost_with_ids( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, ) -> Result<(), BudgetStoreError>

Source

fn reverse_charge_cost_with_ids_and_authority( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, authority: Option<&BudgetEventAuthority>, ) -> Result<(), BudgetStoreError>

Source

fn reduce_charge_cost_with_ids( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, ) -> Result<(), BudgetStoreError>

Source

fn reduce_charge_cost_with_ids_and_authority( &mut self, capability_id: &str, grant_index: usize, cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, authority: Option<&BudgetEventAuthority>, ) -> Result<(), BudgetStoreError>

Source

fn settle_charge_cost_with_ids( &mut self, capability_id: &str, grant_index: usize, exposed_cost_units: u64, realized_cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, ) -> Result<(), BudgetStoreError>

Source

fn settle_charge_cost_with_ids_and_authority( &mut self, capability_id: &str, grant_index: usize, exposed_cost_units: u64, realized_cost_units: u64, hold_id: Option<&str>, event_id: Option<&str>, authority: Option<&BudgetEventAuthority>, ) -> Result<(), BudgetStoreError>

Source

fn list_mutation_events( &self, _limit: usize, _capability_id: Option<&str>, _grant_index: Option<usize>, ) -> Result<Vec<BudgetMutationRecord>, BudgetStoreError>

Source

fn budget_guarantee_level(&self) -> BudgetGuaranteeLevel

Source

fn budget_authority_profile(&self) -> BudgetAuthorityProfile

Source

fn budget_metering_profile(&self) -> BudgetMeteringProfile

Source

fn authorize_budget_hold( &mut self, request: BudgetAuthorizeHoldRequest, ) -> Result<BudgetAuthorizeHoldDecision, BudgetStoreError>

Source

fn reverse_budget_hold( &mut self, request: BudgetReverseHoldRequest, ) -> Result<BudgetReverseHoldDecision, BudgetStoreError>

Source

fn release_budget_hold( &mut self, request: BudgetReleaseHoldRequest, ) -> Result<BudgetReleaseHoldDecision, BudgetStoreError>

Source

fn reconcile_budget_hold( &mut self, request: BudgetReconcileHoldRequest, ) -> Result<BudgetReconcileHoldDecision, BudgetStoreError>

Source

fn capture_budget_hold( &mut self, request: BudgetCaptureHoldRequest, ) -> Result<BudgetCaptureHoldDecision, BudgetStoreError>

Implementors§