Skip to main content

Budget

Struct Budget 

Source
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: RasterLimits

Immutable allowances used by subsequent admission checks.

Implementations§

Source§

impl Budget

Source

pub fn new( size: PixelSize, limits: RasterLimits, ) -> Result<Self, ValidationError>

Creates empty counters after checking positive allowances and pixel count.

Source

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.

Source

pub fn live_bytes(&self) -> u64

Current logical payload bytes, excluding allocation capacity and overhead.

Source

pub fn peak_bytes(&self) -> u64

Highest admitted live-byte total observed by this operation.

Source

pub fn work_done(&self) -> u64

Cumulative admitted algorithm work units, not elapsed time.

Source

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.

Source

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.

Source

pub fn merge_peak(&mut self, peak: u64)

Raises the peak to at least peak, for example after Self::reset_peak.

Source

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.

Source

pub fn bytes(&mut self, amount: u64, path: &str) -> Result<(), ValidationError>

Admits additional live payload and updates the peak; failure leaves counters unchanged.

Source

pub fn work(&mut self, amount: u64, path: &str) -> Result<(), ValidationError>

Admits cumulative work before execution; failure leaves the counter unchanged.

Source

pub fn push<Value>( &mut self, values: &mut Vec<Value>, value: Value, path: &str, ) -> Result<(), ValidationError>

Charges one element’s logical bytes before fallibly reserving and appending. An allocation failure retains the admission charge; discard the partial operation.

Auto Trait Implementations§

§

impl Forget for Budget

§

impl Freeze for Budget

§

impl Move for Budget

§

impl RefUnwindSafe for Budget

§

impl Send for Budget

§

impl Sync for Budget

§

impl Unpin for Budget

§

impl UnsafeUnpin for Budget

§

impl UnwindSafe for Budget

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.