Skip to main content

ruclif_parser_clap/
string.rs

1use crate::ClapArgData;
2
3mod impls;
4
5#[cfg(test)]
6mod tests;
7
8pub type ValueParserFunc = fn(&str) -> Result<String, String>;
9
10#[derive(Debug, PartialEq, Eq)]
11pub struct StringClapArgData {
12    common: ClapArgData,                   // 56 bytes
13    default_value: Option<&'static str>,   // 16 bytes
14    value_parser: Option<ValueParserFunc>, // 8 bytes
15} // 80 bytes
16
17#[derive(Debug, PartialEq, Eq)]
18pub struct StringClapArg {
19    data: StringClapArgData, // 80 bytes
20} // 80 bytes
21
22#[derive(Default, Debug, PartialEq, Eq)]
23pub struct StringClapArgBuilder {
24    name: Option<&'static str>,            // 16 bytes
25    short: Option<char>,                   // 4 bytes
26    long: Option<&'static str>,            // 16 bytes
27    description: Option<&'static str>,     // 16 bytes
28    default_value: Option<&'static str>,   // 16 bytes
29    value_parser: Option<ValueParserFunc>, // 8 bytes
30    state: u8,
31} // 80 bytes
32
33mod builder_state {
34    pub const NAME: usize = 0b1;
35    pub const SHORT: usize = 0b10;
36    pub const LONG: usize = 0b100;
37    pub const DESCRIPTION: usize = 0b1000;
38    pub const EXPECTED: u8 = 0b1111;
39}
40
41mod error_message {
42    pub const MANDATORY_FIELDS_MISSING: &str = "Following mandatory fields are missing: {fields}";
43}