pub trait BudgetGuard: Send + Sync {
// Required methods
fn try_reserve<'life0, 'async_trait>(
&'life0 self,
cost: u64,
) -> Pin<Box<dyn Future<Output = Result<bool, BudgetError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn release<'life0, 'async_trait>(
&'life0 self,
cost: u64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Symmetric reserve/release budget guard.
Implementations gate work on a finite resource pool (rows parsed,
dispatch slots, etc.). Returning Ok(false) from
BudgetGuard::try_reserve is a soft denial — the caller should
back off rather than treat it as an error.
Required Methods§
Sourcefn try_reserve<'life0, 'async_trait>(
&'life0 self,
cost: u64,
) -> Pin<Box<dyn Future<Output = Result<bool, BudgetError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn try_reserve<'life0, 'async_trait>(
&'life0 self,
cost: u64,
) -> Pin<Box<dyn Future<Output = Result<bool, BudgetError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Try to reserve cost units of budget for an upcoming operation.
Returns Ok(true) on success, Ok(false) on soft denial.