cobia/
cobia_enums.rs

1use bitflags::bitflags;
2use std::fmt;
3
4///Registry value type
5///
6///The supported types of registry values.
7///
8#[repr(i32)]
9#[derive(Debug, Copy, Clone, PartialEq, Eq)]
10pub enum CapeRegistryValueType {
11    String=0,
12    Integer=1,
13    UUID=2,
14    Empty=3,
15}
16
17impl CapeRegistryValueType {
18    ///convert from i32 to CapeRegistryValueType
19    ///
20    /// # Arguments
21    ///
22    /// * `value` - i32 value to be converted to CapeRegistryValueType
23    ///
24    /// # Examples
25    ///
26    /// ```
27    /// use cobia;
28    ///let v0=cobia::CapeRegistryValueType::from(0);
29    ///assert_eq!(v0.unwrap(),cobia::CapeRegistryValueType::String);
30    ///let v1=cobia::CapeRegistryValueType::from(1);
31    ///assert_eq!(v1.unwrap(),cobia::CapeRegistryValueType::Integer);
32    ///let v2=cobia::CapeRegistryValueType::from(2);
33    ///assert_eq!(v2.unwrap(),cobia::CapeRegistryValueType::UUID);
34    ///let v3=cobia::CapeRegistryValueType::from(3);
35    ///assert_eq!(v3.unwrap(),cobia::CapeRegistryValueType::Empty);
36    ///let v4=cobia::CapeRegistryValueType::from(-1);
37    ///assert_eq!(v4,None);
38    ///```
39    pub fn from(value: i32) -> Option<CapeRegistryValueType> {
40        match value {
41            0 => Some(CapeRegistryValueType::String),
42            1 => Some(CapeRegistryValueType::Integer),
43            2 => Some(CapeRegistryValueType::UUID),
44            3 => Some(CapeRegistryValueType::Empty),
45            _ => None,
46        }
47    }
48    /// Convert to string
49    pub fn as_string(&self) -> &str {
50        match self {
51			Self::String => "String",
52			Self::Integer => "Integer",
53			Self::UUID => "UUID",
54			Self::Empty => "Empty",
55        }
56    }
57    ///get an iterator
58    ///
59    /// # Examples
60    ///
61    /// ```
62    /// use cobia;
63    /// for capeRegistryValueType in cobia::CapeRegistryValueType::iter() {
64    ///     println!("{}={}",capeRegistryValueType,capeRegistryValueType as i32);
65    /// }
66    /// ```
67    pub fn iter() -> CapeRegistryValueTypeIterator {
68		CapeRegistryValueTypeIterator { current: 0 }
69	}
70}
71
72/// CapeRegistryValueType iterator
73///
74/// Iterates over all CapeRegistryValueType values
75///
76/// Example:
77/// ```
78/// use cobia;
79/// for capeRegistryValueType in cobia::CapeRegistryValueType::iter() {
80///     println!("{}={}",capeRegistryValueType,capeRegistryValueType as i32);
81/// }
82/// ```
83pub struct CapeRegistryValueTypeIterator {
84    current: i32,
85}
86impl Iterator for CapeRegistryValueTypeIterator {
87    type Item = CapeRegistryValueType;
88	fn next(&mut self) -> Option<Self::Item> {
89        if self.current >= 4 {
90			None
91		} else {
92		    let result = CapeRegistryValueType::from(self.current);
93		    self.current += 1;
94		    result
95        }
96	}
97}
98impl fmt::Display for CapeRegistryValueType {
99    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
100        write!(f,"{}",self.as_string())
101	}
102}
103
104///CapeValue data types
105///
106///The supported types of CapeValue values.
107///
108#[repr(i32)]
109#[derive(Debug, Copy, Clone, PartialEq, Eq)]
110pub enum CapeValueType {
111    String=0,
112    Integer=1,
113    Boolean=2,
114    Real=3,
115    Empty=4,
116}
117
118impl CapeValueType {
119    ///convert from i32 to CapeValueType
120    ///
121    /// # Arguments
122    ///
123    /// * `value` - i32 value to be converted to CapeValueType
124    ///
125    /// # Examples
126    ///
127    /// ```
128    /// use cobia;
129    ///let v0=cobia::CapeValueType::from(0);
130    ///assert_eq!(v0.unwrap(),cobia::CapeValueType::String);
131    ///let v1=cobia::CapeValueType::from(1);
132    ///assert_eq!(v1.unwrap(),cobia::CapeValueType::Integer);
133    ///let v2=cobia::CapeValueType::from(2);
134    ///assert_eq!(v2.unwrap(),cobia::CapeValueType::Boolean);
135    ///let v3=cobia::CapeValueType::from(3);
136    ///assert_eq!(v3.unwrap(),cobia::CapeValueType::Real);
137    ///let v4=cobia::CapeValueType::from(4);
138    ///assert_eq!(v4.unwrap(),cobia::CapeValueType::Empty);
139    ///let v5=cobia::CapeValueType::from(-1);
140    ///assert_eq!(v5,None);
141    ///```
142    pub fn from(value: i32) -> Option<CapeValueType> {
143        match value {
144            0 => Some(CapeValueType::String),
145            1 => Some(CapeValueType::Integer),
146            2 => Some(CapeValueType::Boolean),
147            3 => Some(CapeValueType::Real),
148            4 => Some(CapeValueType::Empty),
149            _ => None,
150        }
151    }
152    /// Convert to string
153    pub fn as_string(&self) -> &str {
154        match self {
155			Self::String => "String",
156			Self::Integer => "Integer",
157			Self::Boolean => "Boolean",
158			Self::Real => "Real",
159			Self::Empty => "Empty",
160        }
161    }
162    ///get an iterator
163    ///
164    /// # Examples
165    ///
166    /// ```
167    /// use cobia;
168    /// for capeValueType in cobia::CapeValueType::iter() {
169    ///     println!("{}={}",capeValueType,capeValueType as i32);
170    /// }
171    /// ```
172    pub fn iter() -> CapeValueTypeIterator {
173		CapeValueTypeIterator { current: 0 }
174	}
175}
176
177/// CapeValueType iterator
178///
179/// Iterates over all CapeValueType values
180///
181/// Example:
182/// ```
183/// use cobia;
184/// for capeValueType in cobia::CapeValueType::iter() {
185///     println!("{}={}",capeValueType,capeValueType as i32);
186/// }
187/// ```
188pub struct CapeValueTypeIterator {
189    current: i32,
190}
191impl Iterator for CapeValueTypeIterator {
192    type Item = CapeValueType;
193	fn next(&mut self) -> Option<Self::Item> {
194        if self.current >= 5 {
195			None
196		} else {
197		    let result = CapeValueType::from(self.current);
198		    self.current += 1;
199		    result
200        }
201	}
202}
203impl fmt::Display for CapeValueType {
204    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
205        write!(f,"{}",self.as_string())
206	}
207}
208
209///Service provider types
210///
211///Service type enumeration for PMC instantiation
212///
213#[repr(i32)]
214#[derive(Debug, Copy, Clone, PartialEq, Eq)]
215pub enum CapePMCServiceType {
216    Inproc32=0,
217    Inproc64=1,
218    COM32=2,
219    COM64=3,
220    Remote=4,
221    Local=5,
222}
223
224impl CapePMCServiceType {
225    ///convert from i32 to CapePMCServiceType
226    ///
227    /// # Arguments
228    ///
229    /// * `value` - i32 value to be converted to CapePMCServiceType
230    ///
231    /// # Examples
232    ///
233    /// ```
234    /// use cobia;
235    ///let v0=cobia::CapePMCServiceType::from(0);
236    ///assert_eq!(v0.unwrap(),cobia::CapePMCServiceType::Inproc32);
237    ///let v1=cobia::CapePMCServiceType::from(1);
238    ///assert_eq!(v1.unwrap(),cobia::CapePMCServiceType::Inproc64);
239    ///let v2=cobia::CapePMCServiceType::from(2);
240    ///assert_eq!(v2.unwrap(),cobia::CapePMCServiceType::COM32);
241    ///let v3=cobia::CapePMCServiceType::from(3);
242    ///assert_eq!(v3.unwrap(),cobia::CapePMCServiceType::COM64);
243    ///let v4=cobia::CapePMCServiceType::from(4);
244    ///assert_eq!(v4.unwrap(),cobia::CapePMCServiceType::Remote);
245    ///let v5=cobia::CapePMCServiceType::from(5);
246    ///assert_eq!(v5.unwrap(),cobia::CapePMCServiceType::Local);
247    ///let v6=cobia::CapePMCServiceType::from(-1);
248    ///assert_eq!(v6,None);
249    ///```
250    pub fn from(value: i32) -> Option<CapePMCServiceType> {
251        match value {
252            0 => Some(CapePMCServiceType::Inproc32),
253            1 => Some(CapePMCServiceType::Inproc64),
254            2 => Some(CapePMCServiceType::COM32),
255            3 => Some(CapePMCServiceType::COM64),
256            4 => Some(CapePMCServiceType::Remote),
257            5 => Some(CapePMCServiceType::Local),
258            _ => None,
259        }
260    }
261    /// Convert to string
262    pub fn as_string(&self) -> &str {
263        match self {
264			Self::Inproc32 => "Inproc32",
265			Self::Inproc64 => "Inproc64",
266			Self::COM32 => "COM32",
267			Self::COM64 => "COM64",
268			Self::Remote => "Remote",
269			Self::Local => "Local",
270        }
271    }
272    ///get an iterator
273    ///
274    /// # Examples
275    ///
276    /// ```
277    /// use cobia;
278    /// for capePMCServiceType in cobia::CapePMCServiceType::iter() {
279    ///     println!("{}={}",capePMCServiceType,capePMCServiceType as i32);
280    /// }
281    /// ```
282    pub fn iter() -> CapePMCServiceTypeIterator {
283		CapePMCServiceTypeIterator { current: 0 }
284	}
285}
286
287/// CapePMCServiceType iterator
288///
289/// Iterates over all CapePMCServiceType values
290///
291/// Example:
292/// ```
293/// use cobia;
294/// for capePMCServiceType in cobia::CapePMCServiceType::iter() {
295///     println!("{}={}",capePMCServiceType,capePMCServiceType as i32);
296/// }
297/// ```
298pub struct CapePMCServiceTypeIterator {
299    current: i32,
300}
301impl Iterator for CapePMCServiceTypeIterator {
302    type Item = CapePMCServiceType;
303	fn next(&mut self) -> Option<Self::Item> {
304        if self.current >= 6 {
305			None
306		} else {
307		    let result = CapePMCServiceType::from(self.current);
308		    self.current += 1;
309		    result
310        }
311	}
312}
313impl fmt::Display for CapePMCServiceType {
314    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
315        write!(f,"{}",self.as_string())
316	}
317}
318
319bitflags! {
320    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
321    pub struct CapePMCRegistrationFlags : i32 {
322        const None = 0;
323        const RestrictedThreading = 1;
324    }
325}
326
327bitflags! {
328    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
329    pub struct CapePMCCreationFlags : i32 {
330        const Default = 0;
331        const AllowRestrictedThreading = 1;
332    }
333}
334