Skip to main content

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

1/// Return type representing a single point value.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    conjure_object::private::DeriveWith
8)]
9#[serde(crate = "conjure_object::serde")]
10#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[conjure_object::private::staged_builder::staged_builder]
12#[builder(crate = conjure_object::private::staged_builder, update, inline)]
13pub struct SinglePoint {
14    #[builder(
15        custom(type = super::super::super::super::api::Timestamp, convert = Box::new)
16    )]
17    #[serde(rename = "timestamp")]
18    timestamp: Box<super::super::super::super::api::Timestamp>,
19    #[builder(custom(type = super::Value, convert = Box::new))]
20    #[serde(rename = "value")]
21    value: Box<super::Value>,
22    #[serde(rename = "precisionLoss")]
23    precision_loss: bool,
24}
25impl SinglePoint {
26    /// Constructs a new instance of the type.
27    #[inline]
28    pub fn new(
29        timestamp: super::super::super::super::api::Timestamp,
30        value: super::Value,
31        precision_loss: bool,
32    ) -> Self {
33        Self::builder()
34            .timestamp(timestamp)
35            .value(value)
36            .precision_loss(precision_loss)
37            .build()
38    }
39    #[inline]
40    pub fn timestamp(&self) -> &super::super::super::super::api::Timestamp {
41        &*self.timestamp
42    }
43    #[inline]
44    pub fn value(&self) -> &super::Value {
45        &*self.value
46    }
47    /// Returns true if the result required downcasting to a type with less precision,
48    /// for example if the input series was Int64 and the result is a Float64.
49    #[inline]
50    pub fn precision_loss(&self) -> bool {
51        self.precision_loss
52    }
53}