1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

// Provider structs must be stable
#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)]

//! Provider structs for digital data.

use alloc::borrow::Cow;
use icu_provider::prelude::*;

#[icu_provider::data_struct(DigitalDurationDataV1Marker = "duration/digital@1")]
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::duration::provider))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]

/// A struct containing digital duration data (durationUnit-type-* patterns).
pub struct DigitalDurationDataV1<'data> {
    /// The separator between the hour, minute, and second fields.
    #[cfg_attr(feature = "serde", serde(borrow))]
    pub separator: Cow<str, 'data>,

    /// The number of digits to pad hours when hour, minutes and seconds must be displayed.
    /// Calculated from the hms pattern.
    pub hms_padding: HmsPadding,

    /// The number of digits to pad hours when only hour and minutes must be displayed.
    /// Calculated from the hm pattern.
    pub hm_padding: HmPadding,

    /// The number of digits to pad minutes when only minutes and seconds must be displayed.
    /// Calculated from the ms pattern.
    pub ms_padding: MsPadding,
}

#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::duration::provider))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
/// A struct containing the number of digits to pad hours, minutes, and seconds.
pub struct HmsPadding {
    /// Hour padding.
    pub h: u8,
    /// Minute padding.
    pub m: u8,
    /// Second padding.
    pub s: u8,
}

#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::duration::provider))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
/// A struct containing the number of digits to pad minutes, and seconds.
pub struct MsPadding {
    /// Minute padding.
    pub m: u8,
    /// Second padding.
    pub s: u8,
}

#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
#[cfg_attr(feature = "datagen", databake(path = icu_experimental::duration::provider))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
/// A struct containing the number of digits to pad hours and minutes.
pub struct HmPadding {
    /// Hour padding.
    pub h: u8,
    /// Minute padding.
    pub m: u8,
}