pub struct SharedSearchBudget { /* private fields */ }Expand description
One forest’s usage behind a shared handle, so the branch tool loops can reserve before every action while the forest holds the same ledgered totals (Gate AC: reservations precede actions; usage never decreases; usage never persists above a limit — overflow clamps at the limit and closes the forest).
Implementations§
pub fn new(limits: SearchLimits) -> Self
Sourcepub fn with_usage(limits: SearchLimits, usage: SearchUsage) -> Self
pub fn with_usage(limits: SearchLimits, usage: SearchUsage) -> Self
Open with prior usage (resume: an interrupted forest’s consumption is not silently forgotten).
Sourcepub fn bind_forest(&self, forest_id: &str)
pub fn bind_forest(&self, forest_id: &str)
Bind the owning forest’s identity (set once at forest opening).
Sourcepub fn set_epoch(&self, epoch: u64)
pub fn set_epoch(&self, epoch: u64)
Advance the identity’s epoch (set at each frontier epoch opening).
Sourcepub fn identity(&self) -> (String, u64)
pub fn identity(&self) -> (String, u64)
The bound (forest_id, epoch); the forest id is empty outside a
forest.
pub fn limits(&self) -> &SearchLimits
Sourcepub fn reserve(&self, request: ReservationRequest) -> Result<ReservationTicket>
pub fn reserve(&self, request: ReservationRequest) -> Result<ReservationTicket>
Reserve one action’s resources before it starts. A refusal marks the handle denied so the forest can abandon the branch gracefully.
Sourcepub fn settle(
&self,
ticket: ReservationTicket,
actual: ReservationRequest,
) -> Result<()>
pub fn settle( &self, ticket: ReservationTicket, actual: ReservationRequest, ) -> Result<()>
Settle one action: release the unused part of the ticket; charge any overshoot clamped at the limits. Overshoot closes the forest and errs — the caller ledgers the overflow as an observation.
Sourcepub fn charge_elapsed(&self, seconds: u64) -> Result<()>
pub fn charge_elapsed(&self, seconds: u64) -> Result<()>
Charge one wall-clock interval, clamped at the limit; crossing it closes the forest.
Sourcepub fn headroom(&self, request: &ReservationRequest) -> bool
pub fn headroom(&self, request: &ReservationRequest) -> bool
Non-consuming check: would this reservation be admitted right now?
pub fn snapshot(&self) -> SearchUsage
Sourcepub fn close(&self) -> SearchUsage
pub fn close(&self) -> SearchUsage
Terminal snapshot for SearchClosed; the forest cannot reopen.
pub fn is_closed(&self) -> bool
Sourcepub fn take_denied(&self) -> bool
pub fn take_denied(&self) -> bool
Whether a reservation was refused since the last call (one-shot).
Trait Implementations§
Source§fn clone(&self) -> SharedSearchBudget
fn clone(&self) -> SharedSearchBudget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.