pub struct EnergyBudget {
pub max_joules: Option<f64>,
pub max_watts: Option<f64>,
pub max_temp_delta: Option<f64>,
pub span: Span,
}Expand description
Energy budget constraints for a function or block.
These constraints can be attached to functions via the #[energy_budget(...)] attribute
to specify limits on energy consumption, power usage, and temperature impact.
§Example
#[energy_budget(max_joules = 0.5)]
fn process(data: &[f32]) -> f32 {
// Compiler can warn if estimated energy > 0.5J
}
#[energy_budget(max_joules = 1.0, max_temp_delta = 5.0)]
fn intensive_compute() {
// Also track temperature increase
}Fields§
§max_joules: Option<f64>Maximum energy consumption in joules
max_watts: Option<f64>Maximum power consumption in watts
max_temp_delta: Option<f64>Maximum temperature delta in Celsius
span: SpanSource span for error reporting
Implementations§
Source§impl EnergyBudget
impl EnergyBudget
Sourcepub const fn with_max_joules(joules: f64, span: Span) -> Self
pub const fn with_max_joules(joules: f64, span: Span) -> Self
Create an energy budget with max_joules constraint
Sourcepub const fn has_constraints(&self) -> bool
pub const fn has_constraints(&self) -> bool
Check if this energy budget has any constraints
Sourcepub const fn set_max_joules(&mut self, joules: f64)
pub const fn set_max_joules(&mut self, joules: f64)
Set max_joules constraint
Sourcepub const fn set_max_watts(&mut self, watts: f64)
pub const fn set_max_watts(&mut self, watts: f64)
Set max_watts constraint
Sourcepub const fn set_max_temp_delta(&mut self, delta: f64)
pub const fn set_max_temp_delta(&mut self, delta: f64)
Set max_temp_delta constraint
Trait Implementations§
Source§impl Clone for EnergyBudget
impl Clone for EnergyBudget
Source§fn clone(&self) -> EnergyBudget
fn clone(&self) -> EnergyBudget
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EnergyBudget
impl Debug for EnergyBudget
Source§impl Default for EnergyBudget
impl Default for EnergyBudget
Source§impl PartialEq for EnergyBudget
impl PartialEq for EnergyBudget
impl StructuralPartialEq for EnergyBudget
Auto Trait Implementations§
impl Freeze for EnergyBudget
impl RefUnwindSafe for EnergyBudget
impl Send for EnergyBudget
impl Sync for EnergyBudget
impl Unpin for EnergyBudget
impl UnwindSafe for EnergyBudget
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