pub struct Budget {
pub limits: RasterLimits,
/* private fields */
}Expand description
Mutable admission counters for one bounded geometry or rendering operation.
Callers release transient payloads from live_bytes; work is never refunded.
Fields§
§limits: RasterLimitsImmutable allowances used by subsequent admission checks.
Implementations§
Source§impl Budget
impl Budget
Sourcepub fn new(
size: PixelSize,
limits: RasterLimits,
) -> Result<Self, ValidationError>
pub fn new( size: PixelSize, limits: RasterLimits, ) -> Result<Self, ValidationError>
Creates empty counters after checking positive allowances and pixel count.
Sourcepub fn resume(
limits: RasterLimits,
live_bytes: u64,
peak_bytes: u64,
work: u64,
) -> Self
pub fn resume( limits: RasterLimits, live_bytes: u64, peak_bytes: u64, work: u64, ) -> Self
Resumes counters recorded by an earlier planning pass over the same limits.
The caller vouches that live_bytes, peak_bytes and work already passed
admission against limits; nothing is re-checked.
Sourcepub fn live_bytes(&self) -> u64
pub fn live_bytes(&self) -> u64
Current logical payload bytes, excluding allocation capacity and overhead.
Sourcepub fn peak_bytes(&self) -> u64
pub fn peak_bytes(&self) -> u64
Highest admitted live-byte total observed by this operation.
Sourcepub fn release(&mut self, amount: u64)
pub fn release(&mut self, amount: u64)
Returns transient payload previously admitted with Self::bytes; the peak is kept.
Releasing more than is live is a caller bug and saturates at zero rather than wrapping.
Sourcepub fn reset_peak(&mut self) -> u64
pub fn reset_peak(&mut self) -> u64
Restarts peak tracking at the current live bytes and returns the previous peak.
Use it to measure one nested operation, then call Self::merge_peak with the
returned value so the enclosing operation’s peak is not lost.
Sourcepub fn merge_peak(&mut self, peak: u64)
pub fn merge_peak(&mut self, peak: u64)
Raises the peak to at least peak, for example after Self::reset_peak.
Sourcepub fn set_live_bytes(&mut self, live_bytes: u64)
pub fn set_live_bytes(&mut self, live_bytes: u64)
Replaces the live-byte count with an externally measured total, raising the peak if needed.
Sourcepub fn bytes(&mut self, amount: u64, path: &str) -> Result<(), ValidationError>
pub fn bytes(&mut self, amount: u64, path: &str) -> Result<(), ValidationError>
Admits additional live payload and updates the peak; failure leaves counters unchanged.