Skip to main content

PluginResult

Struct PluginResult 

Source
pub struct PluginResult {
    pub compliance_status: PluginComplianceStatus,
    pub metrics: HashMap<String, f64>,
    pub extra: Option<Value>,
    pub violations: Vec<PluginFinding>,
    pub warnings: Vec<PluginFinding>,
}
Expand description

Compliance result returned by the plugin.

metrics is a sector-extensible map of named numeric values. Use the METRIC_* constants for the three well-known fields; plugins may add sector-specific keys ("water_use_litres", "pef_score", …).

§Aligning with ComplianceResult on the host

co2e_score           ← metrics["co2e_score"]
repairability_index  ← metrics["repairability_index"]
recycled_content_pct ← metrics["recycled_content_pct"]
compliance_status    ← PluginComplianceStatus → ComplianceStatus (typed map)
violations/warnings  ← PluginFinding → ComplianceFinding (host blocks on violations)

Fields§

§compliance_status: PluginComplianceStatus

Typed compliance determination.

§metrics: HashMap<String, f64>

Sector-extensible keyed metric map (all values finite f64).

Serialisation fails on a non-finite value (NaN/Infinity) rather than silently coercing it to JSON null, so a metric inserted directly into this pub field (bypassing the with_metric guard) cannot slip through the ABI envelope as a spurious success.

§extra: Option<Value>

Non-numeric sector-specific data (free-form; stored verbatim in extra).

§violations: Vec<PluginFinding>

Binding findings — the host blocks publish for an in-force sector. Empty for passthrough / not-assessed determinations. (ABI 1.1+)

§warnings: Vec<PluginFinding>

Advisory / experimental findings — surfaced but never block publish (e.g. recycled-content thresholds that are not yet in force). (ABI 1.1+)

Implementations§

Source§

impl PluginResult

Source

pub fn new(status: PluginComplianceStatus) -> Self

Construct a result carrying only a compliance status.

Source

pub fn with_metric(self, key: &str, value: f64) -> Self

Insert a metric unconditionally (non-finite values are silently dropped).

Source

pub fn maybe_metric(self, key: &str, value: Option<f64>) -> Self

Insert a metric only when value is Some (non-finite values dropped).

Source

pub fn with_extra(self, extra: Value) -> Self

Attach free-form non-numeric extra data.

Source

pub fn with_violation(self, finding: PluginFinding) -> Self

Append a binding violation (host blocks publish for an in-force sector).

Source

pub fn with_warning(self, finding: PluginFinding) -> Self

Append an advisory warning (surfaced, never blocks publish).

Source

pub fn co2e_score(&self) -> Option<f64>

Source

pub fn repairability_index(&self) -> Option<f64>

Source

pub fn recycled_content_pct(&self) -> Option<f64>

Trait Implementations§

Source§

impl Clone for PluginResult

Source§

fn clone(&self) -> PluginResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PluginResult

Source§

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

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

impl<'de> Deserialize<'de> for PluginResult

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PluginResult

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.