pub struct BudgetBuilder { /* private fields */ }Expand description
Builder for BudgetTracker.
Implementations§
Source§impl BudgetBuilder
impl BudgetBuilder
Sourcepub fn max_usd(self, max: f64) -> Self
pub fn max_usd(self, max: f64) -> Self
Hard ceiling in USD. Once the running total hits this value,
BudgetTracker::check returns Error::BudgetExceeded.
Sourcepub fn warn_at_usd(self, warn: f64) -> Self
pub fn warn_at_usd(self, warn: f64) -> Self
Warning threshold in USD. BudgetBuilder::on_warning fires
the first time the running total reaches this value.
Sourcepub fn on_warning<F>(self, f: F) -> Self
pub fn on_warning<F>(self, f: F) -> Self
Callback fired once when warn_at_usd is crossed. The argument
is the running total at the crossing.
Sourcepub fn on_exceeded<F>(self, f: F) -> Self
pub fn on_exceeded<F>(self, f: F) -> Self
Callback fired once when max_usd is crossed. The argument is
the running total at the crossing.
Sourcepub fn build(self) -> BudgetTracker
pub fn build(self) -> BudgetTracker
Finish construction.
Trait Implementations§
Source§impl Default for BudgetBuilder
impl Default for BudgetBuilder
Source§fn default() -> BudgetBuilder
fn default() -> BudgetBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BudgetBuilder
impl !RefUnwindSafe for BudgetBuilder
impl Send for BudgetBuilder
impl Sync for BudgetBuilder
impl Unpin for BudgetBuilder
impl UnsafeUnpin for BudgetBuilder
impl !UnwindSafe for BudgetBuilder
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
Mutably borrows from an owned value. Read more