pub enum DashboardMeasure {
Exact,
Count,
}Expand description
How a card’s value is read out of its source’s answer. Neither reading is arithmetic on the source’s behalf.
use majordomus_cli::capability::builtin::dashboard::DashboardMeasure;
use serde_json::json;
let answer = json!({ "status": "warn", "tallies": { "ok": 6 }, "overlaps": [1, 2] });
// exact: the value at the pointer, null when there is none
assert_eq!(DashboardMeasure::Exact.read(&answer, "/status"), json!("warn"));
assert_eq!(DashboardMeasure::Exact.read(&answer, "/tallies/fail"), json!(null));
// count: a number as it stands, a list or map by its length, and an omitted one is none
assert_eq!(DashboardMeasure::Count.read(&answer, "/tallies/ok"), json!(6));
assert_eq!(DashboardMeasure::Count.read(&answer, "/overlaps"), json!(2));
assert_eq!(DashboardMeasure::Count.read(&answer, "/tallies/fail"), json!(0));Variants§
Exact
The value at the pointer, exactly; null when the pointer resolves to nothing.
Count
The number at the pointer, or the length of the list or map there; 0 when the
source left it out, which is how the sources say an empty list or a zero tally.
Implementations§
Source§impl DashboardMeasure
impl DashboardMeasure
Sourcepub fn read(self, answer: &Value, pointer: &str) -> Value
pub fn read(self, answer: &Value, pointer: &str) -> Value
Read the card’s value out of the source’s answer.
use majordomus_cli::capability::builtin::dashboard::DashboardMeasure;
use serde_json::json;
let answer = json!({ "issue": { "id": "I0001" } });
assert_eq!(DashboardMeasure::Exact.read(&answer, "/issue/id"), json!("I0001"));
assert_eq!(DashboardMeasure::Count.read(&answer, "/blockers"), json!(0));Trait Implementations§
Source§impl Clone for DashboardMeasure
impl Clone for DashboardMeasure
Source§fn clone(&self) -> DashboardMeasure
fn clone(&self) -> DashboardMeasure
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 moreimpl Copy for DashboardMeasure
Source§impl Debug for DashboardMeasure
impl Debug for DashboardMeasure
Source§impl<'de> Deserialize<'de> for DashboardMeasure
impl<'de> Deserialize<'de> for DashboardMeasure
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
impl Eq for DashboardMeasure
Source§impl JsonSchema for DashboardMeasure
impl JsonSchema for DashboardMeasure
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for DashboardMeasure
impl PartialEq for DashboardMeasure
Source§fn eq(&self, other: &DashboardMeasure) -> bool
fn eq(&self, other: &DashboardMeasure) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for DashboardMeasure
impl Serialize for DashboardMeasure
impl StructuralPartialEq for DashboardMeasure
Auto Trait Implementations§
impl Freeze for DashboardMeasure
impl RefUnwindSafe for DashboardMeasure
impl Send for DashboardMeasure
impl Sync for DashboardMeasure
impl Unpin for DashboardMeasure
impl UnsafeUnpin for DashboardMeasure
impl UnwindSafe for DashboardMeasure
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.