1use super::Index;
2
3pub trait Information {
4 fn has_name(&self) -> bool;
5
6 fn has_force(&self) -> bool;
7
8 fn has_alias(&self) -> bool;
9
10 fn has_index(&self) -> bool;
11
12 fn has_help(&self) -> bool;
13
14 fn has_ctor(&self) -> bool;
15
16 fn name(&self) -> Option<&str>;
17
18 fn force(&self) -> Option<bool>;
19
20 fn alias(&self) -> Option<&Vec<String>>;
21
22 fn index(&self) -> Option<&Index>;
23
24 fn help(&self) -> Option<&str>;
25
26 fn ctor(&self) -> Option<&str>;
27
28 fn take_name(&mut self) -> Option<String>;
29
30 fn take_force(&mut self) -> Option<bool>;
31
32 fn take_alias(&mut self) -> Option<Vec<String>>;
33
34 fn take_index(&mut self) -> Option<Index>;
35
36 fn take_help(&mut self) -> Option<String>;
37
38 fn take_ctor(&mut self) -> Option<String>;
39}
40
41#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
43pub struct ConstrctInfo {
44 pub(crate) name: Option<String>,
45
46 pub(crate) alias: Option<Vec<String>>,
47
48 pub(crate) force: Option<bool>,
49
50 pub(crate) index: Option<Index>,
51
52 pub(crate) help: Option<String>,
53
54 pub(crate) ctor: Option<String>,
55}
56
57impl ConstrctInfo {
58 pub fn with_name(mut self, name: Option<String>) -> Self {
59 self.name = name;
60 self
61 }
62
63 pub fn with_help(mut self, help: Option<String>) -> Self {
64 self.help = help;
65 self
66 }
67
68 pub fn with_alias(mut self, alias: Option<Vec<String>>) -> Self {
69 self.alias = alias;
70 self
71 }
72
73 pub fn with_force(mut self, force: Option<bool>) -> Self {
74 self.force = force;
75 self
76 }
77
78 pub fn with_index(mut self, index: Option<Index>) -> Self {
79 self.index = index;
80 self
81 }
82
83 pub fn with_ctor(mut self, ctor: Option<String>) -> Self {
84 self.ctor = ctor;
85 self
86 }
87}
88
89impl Information for ConstrctInfo {
90 fn has_name(&self) -> bool {
91 self.name.is_some()
92 }
93
94 fn has_force(&self) -> bool {
95 self.force.is_some()
96 }
97
98 fn has_alias(&self) -> bool {
99 self.alias.is_some()
100 }
101
102 fn has_index(&self) -> bool {
103 self.index.is_some()
104 }
105
106 fn has_help(&self) -> bool {
107 self.help.is_some()
108 }
109
110 fn has_ctor(&self) -> bool {
111 self.ctor.is_some()
112 }
113
114 fn name(&self) -> Option<&str> {
115 self.name.as_deref()
116 }
117
118 fn force(&self) -> Option<bool> {
119 self.force
120 }
121
122 fn alias(&self) -> Option<&Vec<String>> {
123 self.alias.as_ref()
124 }
125
126 fn index(&self) -> Option<&Index> {
127 self.index.as_ref()
128 }
129
130 fn help(&self) -> Option<&str> {
131 self.help.as_deref()
132 }
133
134 fn ctor(&self) -> Option<&str> {
135 self.ctor.as_deref()
136 }
137
138 fn take_name(&mut self) -> Option<String> {
139 self.name.take()
140 }
141
142 fn take_force(&mut self) -> Option<bool> {
143 self.force.take()
144 }
145
146 fn take_alias(&mut self) -> Option<Vec<String>> {
147 self.alias.take()
148 }
149
150 fn take_index(&mut self) -> Option<Index> {
151 self.index.take()
152 }
153
154 fn take_help(&mut self) -> Option<String> {
155 self.help.take()
156 }
157
158 fn take_ctor(&mut self) -> Option<String> {
159 self.ctor.take()
160 }
161}