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
use crate::{BinaryFormat, BoolFormat, NumberFormat, StringFormat};

/// unknown format
#[derive(Debug, Clone)]
pub struct UnknownFormat {
    /// min width
    pub min_width: Option<usize>,
    /// max width
    pub max_width: Option<usize>,
}

impl UnknownFormat {
    /// min width
    pub fn min_width(mut self, width: usize) -> UnknownFormat {
        self.min_width = Some(width);
        self
    }

    /// max width
    pub fn max_width(mut self, width: usize) -> UnknownFormat {
        self.max_width = Some(width);
        self
    }
}

impl From<UnknownFormat> for NumberFormat {
    fn from(unknown_format: UnknownFormat) -> Self {
        NumberFormat::new()
            .min_width_option(unknown_format.min_width)
            .max_width_option(unknown_format.max_width)
    }
}

impl From<UnknownFormat> for BinaryFormat {
    fn from(unknown_format: UnknownFormat) -> Self {
        BinaryFormat::new()
            .min_width_option(unknown_format.min_width)
            .max_width_option(unknown_format.max_width)
    }
}

impl From<UnknownFormat> for StringFormat {
    fn from(unknown_format: UnknownFormat) -> Self {
        StringFormat::new()
            .min_width_option(unknown_format.min_width)
            .max_width_option(unknown_format.max_width)
    }
}

impl From<UnknownFormat> for BoolFormat {
    fn from(unknown_format: UnknownFormat) -> Self {
        BoolFormat::new()
            .min_width_option(unknown_format.min_width)
            .max_width_option(unknown_format.max_width)
    }
}