Skip to main content

nominal_api/conjure/objects/scout/compute/api/
numeric_bucket.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct NumericBucket {
13    #[builder(default, into)]
14    #[serde(rename = "min", skip_serializing_if = "Option::is_none", default)]
15    #[derive_with(with = conjure_object::private::DoubleWrapper)]
16    min: Option<f64>,
17    #[builder(default, into)]
18    #[serde(rename = "max", skip_serializing_if = "Option::is_none", default)]
19    #[derive_with(with = conjure_object::private::DoubleWrapper)]
20    max: Option<f64>,
21    #[builder(default, into)]
22    #[serde(rename = "mean", skip_serializing_if = "Option::is_none", default)]
23    #[derive_with(with = conjure_object::private::DoubleWrapper)]
24    mean: Option<f64>,
25    #[builder(default, into)]
26    #[serde(rename = "count", skip_serializing_if = "Option::is_none", default)]
27    count: Option<conjure_object::SafeLong>,
28    #[builder(default, into)]
29    #[serde(rename = "variance", skip_serializing_if = "Option::is_none", default)]
30    #[derive_with(with = conjure_object::private::DoubleWrapper)]
31    variance: Option<f64>,
32    #[builder(
33        default,
34        custom(
35            type = impl
36            Into<Option<super::NumericPoint>>,
37            convert = |v|v.into().map(Box::new)
38        )
39    )]
40    #[serde(rename = "firstPoint", skip_serializing_if = "Option::is_none", default)]
41    first_point: Option<Box<super::NumericPoint>>,
42    #[builder(
43        default,
44        custom(
45            type = impl
46            Into<Option<super::NumericPoint>>,
47            convert = |v|v.into().map(Box::new)
48        )
49    )]
50    #[serde(rename = "lastPoint", skip_serializing_if = "Option::is_none", default)]
51    last_point: Option<Box<super::NumericPoint>>,
52}
53impl NumericBucket {
54    /// Constructs a new instance of the type.
55    #[inline]
56    pub fn new() -> Self {
57        Self::builder().build()
58    }
59    #[inline]
60    pub fn min(&self) -> Option<f64> {
61        self.min.as_ref().map(|o| *o)
62    }
63    #[inline]
64    pub fn max(&self) -> Option<f64> {
65        self.max.as_ref().map(|o| *o)
66    }
67    #[inline]
68    pub fn mean(&self) -> Option<f64> {
69        self.mean.as_ref().map(|o| *o)
70    }
71    #[inline]
72    pub fn count(&self) -> Option<conjure_object::SafeLong> {
73        self.count.as_ref().map(|o| *o)
74    }
75    /// The population variance of the bucket. If the bucket has only one value, this will be 0.
76    #[inline]
77    pub fn variance(&self) -> Option<f64> {
78        self.variance.as_ref().map(|o| *o)
79    }
80    #[inline]
81    pub fn first_point(&self) -> Option<&super::NumericPoint> {
82        self.first_point.as_ref().map(|o| &**o)
83    }
84    /// Will be empty if the bucket only has a single point.
85    #[inline]
86    pub fn last_point(&self) -> Option<&super::NumericPoint> {
87        self.last_point.as_ref().map(|o| &**o)
88    }
89}