Skip to main content

wire

Function wire 

Source
pub fn wire<T: Serialize>(value: &T) -> String
Expand description

The string a value serialises to, as every JSON surface spells it: EconomicsMetricStatus::NotMeasured is not_measured. A renderer that prints an enum uses this rather than Debug, so that a page and the API never spell one state two ways. A value that does not serialise to a string is given as its JSON text.

use majordomus_cli::economics::wire;
use majordomus_cli::economics::model::{EconomicsFreshness, EconomicsMetricStatus};
assert_eq!(wire(&EconomicsMetricStatus::NotMeasured), "not_measured");
assert_eq!(wire(&EconomicsFreshness::NoEvidence), "no_evidence");
assert_eq!(wire(&3), "3");