EnergyViolation

Struct EnergyViolation 

Source
pub struct EnergyViolation {
    pub kind: EnergyViolationKind,
    pub budget: f64,
    pub estimated: f64,
    pub budget_span: Span,
    pub code_span: Span,
    pub confidence: f64,
    pub message: String,
    pub callee_chain: Vec<(String, f64)>,
}
Expand description

Energy violation detected during compile-time analysis.

This is returned when energy estimation determines that a function’s estimated energy consumption exceeds its declared budget.

Fields§

§kind: EnergyViolationKind

The kind of violation

§budget: f64

The declared budget value

§estimated: f64

The estimated actual value

§budget_span: Span

Source span where the budget was declared

§code_span: Span

Source span of the violating code (e.g., function body)

§confidence: f64

Confidence level of the estimate (0.0 to 1.0)

§message: String

Human-readable description of the violation

§callee_chain: Vec<(String, f64)>

Callee chain showing where the energy went: (callee_name, cost_joules) Populated only for transitive budget violations

Implementations§

Source§

impl EnergyViolation

Source

pub fn format_joules(joules: f64) -> String

Format a joule value with appropriate SI prefix for readability. Values >= 0.001J use plain joules; smaller values use mJ/uJ/nJ/pJ.

Source

pub fn joules( budget: f64, estimated: f64, budget_span: Span, code_span: Span, confidence: f64, ) -> Self

Create a new joule budget violation

Source

pub fn watts( budget: f64, estimated: f64, budget_span: Span, code_span: Span, confidence: f64, ) -> Self

Create a new power budget violation

Source

pub fn temp_delta( budget: f64, estimated: f64, budget_span: Span, code_span: Span, confidence: f64, ) -> Self

Create a new temperature budget violation

Source

pub fn excess_percentage(&self) -> f64

Get the percentage by which the estimate exceeds the budget

Trait Implementations§

Source§

impl Clone for EnergyViolation

Source§

fn clone(&self) -> EnergyViolation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EnergyViolation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for EnergyViolation

Source§

fn eq(&self, other: &EnergyViolation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for EnergyViolation

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.