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>),
}