Skip to main content

nominal_api/conjure/objects/scout/chartdefinition/api/
number_format.rs

1/// Number format for numeric cells, eg 1e4 | 10000 | 10,000.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash
12)]
13#[serde(crate = "conjure_object::serde")]
14#[conjure_object::private::staged_builder::staged_builder]
15#[builder(crate = conjure_object::private::staged_builder, update, inline)]
16pub struct NumberFormat {
17    #[builder(default, into)]
18    #[serde(rename = "sigFigs", skip_serializing_if = "Option::is_none", default)]
19    sig_figs: Option<i32>,
20    #[builder(default, into)]
21    #[serde(rename = "displayOption", skip_serializing_if = "Option::is_none", default)]
22    display_option: Option<super::NumberFormatDisplayOption>,
23    #[builder(default, into)]
24    #[serde(
25        rename = "fixedDecimalPlaces",
26        skip_serializing_if = "Option::is_none",
27        default
28    )]
29    fixed_decimal_places: Option<i32>,
30    #[builder(
31        default,
32        custom(
33            type = impl
34            Into<Option<super::DecimalPlaces>>,
35            convert = |v|v.into().map(Box::new)
36        )
37    )]
38    #[serde(rename = "decimalPlaces", skip_serializing_if = "Option::is_none", default)]
39    decimal_places: Option<Box<super::DecimalPlaces>>,
40}
41impl NumberFormat {
42    /// Constructs a new instance of the type.
43    #[inline]
44    pub fn new() -> Self {
45        Self::builder().build()
46    }
47    /// Include the specified number of significant figures, rounding if needed.
48    #[inline]
49    pub fn sig_figs(&self) -> Option<i32> {
50        self.sig_figs.as_ref().map(|o| *o)
51    }
52    /// The base display format for the number.
53    #[inline]
54    pub fn display_option(&self) -> Option<&super::NumberFormatDisplayOption> {
55        self.display_option.as_ref().map(|o| &*o)
56    }
57    #[deprecated(note = "use decimalPlaces instead")]
58    #[inline]
59    pub fn fixed_decimal_places(&self) -> Option<i32> {
60        self.fixed_decimal_places.as_ref().map(|o| *o)
61    }
62    /// Options for formatting the decimal part of number.
63    #[inline]
64    pub fn decimal_places(&self) -> Option<&super::DecimalPlaces> {
65        self.decimal_places.as_ref().map(|o| &**o)
66    }
67}