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
use std::collections::BTreeSet;
pub struct TypeLimits {
reader: &'static winmd::TypeReader,
pub inner: BTreeSet<NamespaceTypes>,
}
impl TypeLimits {
pub fn new(reader: &'static winmd::TypeReader) -> Self {
Self {
reader,
inner: BTreeSet::new(),
}
}
pub fn insert(&mut self, mut limit: NamespaceTypes) -> Result<(), &'static str> {
if let Some(namespace) = self
.reader
.find_lowercase_namespace(&limit.namespace.to_lowercase())
{
limit.namespace = namespace;
self.inner.insert(limit);
Ok(())
} else {
Err(limit.namespace)
}
}
pub fn limits(&self) -> impl Iterator<Item = &NamespaceTypes> {
self.inner.iter()
}
}
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)]
pub struct NamespaceTypes {
pub namespace: &'static str,
pub limit: TypeLimit,
}
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)]
pub enum TypeLimit {
All,
Some(Vec<String>),
}