pub struct PluginResult {
pub compliance_status: PluginComplianceStatus,
pub metrics: HashMap<String, f64>,
pub extra: Option<Value>,
}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)Fields§
§compliance_status: PluginComplianceStatusTyped compliance determination.
metrics: HashMap<String, f64>Sector-extensible keyed metric map (all values finite f64).
extra: Option<Value>Non-numeric sector-specific data (free-form; stored verbatim in extra).
Implementations§
Source§impl PluginResult
impl PluginResult
Sourcepub fn new(status: PluginComplianceStatus) -> Self
pub fn new(status: PluginComplianceStatus) -> Self
Construct a result carrying only a compliance status.
Sourcepub fn with_metric(self, key: &str, value: f64) -> Self
pub fn with_metric(self, key: &str, value: f64) -> Self
Insert a metric unconditionally (non-finite values are silently dropped).
Sourcepub fn maybe_metric(self, key: &str, value: Option<f64>) -> Self
pub fn maybe_metric(self, key: &str, value: Option<f64>) -> Self
Insert a metric only when value is Some (non-finite values dropped).
Sourcepub fn with_extra(self, extra: Value) -> Self
pub fn with_extra(self, extra: Value) -> Self
Attach free-form non-numeric extra data.
pub fn co2e_score(&self) -> Option<f64>
pub fn repairability_index(&self) -> Option<f64>
pub fn recycled_content_pct(&self) -> Option<f64>
Trait Implementations§
Source§impl Clone for PluginResult
impl Clone for PluginResult
Source§fn clone(&self) -> PluginResult
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PluginResult
impl Debug for PluginResult
Source§impl<'de> Deserialize<'de> for PluginResult
impl<'de> Deserialize<'de> for PluginResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PluginResult
impl RefUnwindSafe for PluginResult
impl Send for PluginResult
impl Sync for PluginResult
impl Unpin for PluginResult
impl UnsafeUnpin for PluginResult
impl UnwindSafe for PluginResult
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