pretty_duration/pretty_duration_lib/
pretty_duration_options.rs

1#[derive(Copy, Clone)]
2pub enum PrettyDurationOutputFormat {
3    Compact,
4    Expanded,
5    Colon,
6}
7
8/// Structure that hold the text to display for the singular and plural form of each unit
9#[derive(Clone)]
10pub struct PrettyDurationLabels {
11    pub year: &'static str,
12    pub month: &'static str,
13    pub day: &'static str,
14    pub hour: &'static str,
15    pub minute: &'static str,
16    pub second: &'static str,
17    pub millisecond: &'static str,
18}
19/// Options to customize the output [String]
20#[derive(Clone)]
21pub struct PrettyDurationOptions {
22    /// Output format [PrettyDurationOutputFormat]
23    pub output_format: Option<PrettyDurationOutputFormat>,
24    /// Label to use when a unit of time must be singular
25    pub singular_labels: Option<PrettyDurationLabels>,
26    // Label to use when a unit of time must be plural
27    pub plural_labels: Option<PrettyDurationLabels>,
28}
29
30// Need to fine a way to do like in TypeScript with Required<PrettyDurationOptions>
31// Private structure that define all fields from [PrettyDurationOptions] without
32// being optional.
33#[derive(Clone)]
34pub struct PrettyDurationOptionsWithDefault {
35    pub output_format: PrettyDurationOutputFormat,
36    pub singular_labels: PrettyDurationLabels,
37    pub plural_labels: PrettyDurationLabels,
38}