Skip to main content

budget_context/
lib.rs

1//! Hierarchical, process-local resource budgets for concurrent Rust task trees.
2//!
3//! A [`Budget`] accounts for arbitrary integer-valued [`Resource`]s. Child
4//! budgets may add tighter limits, while every successful operation is also
5//! recorded against every ancestor. [`Reservation`] and [`ReservationSet`]
6//! provide cancellation-safe capacity claims which release on drop.
7//!
8//! The crate is cooperative: code must receive and consult a budget for it to
9//! be constrained. It is not a security sandbox, rate limiter, billing ledger,
10//! or distributed quota service.
11
12mod budget;
13mod error;
14mod reservation;
15mod resource;
16mod snapshot;
17
18#[cfg(feature = "tokio")]
19mod tokio_runtime;
20
21pub use budget::{Budget, BudgetBuilder};
22pub use error::{BudgetBuildError, BudgetError, ResourceError};
23pub use reservation::{Reservation, ReservationSet};
24pub use resource::{BudgetId, Resource};
25pub use snapshot::{BudgetSnapshot, Remaining, ResourceSnapshot};
26
27// Keep the README's Rust examples compiled without duplicating it in the
28// published API documentation. The README's Tokio example requires all
29// features, which is how the documentation test job invokes rustdoc.
30#[cfg(all(doctest, feature = "tokio"))]
31#[doc = include_str!("../README.md")]
32pub struct ReadmeDoctests;