#[derive(Default)]
pub struct Registry {
- libs: HashMap<String, Vec<shapelib::Contents>>,
+ libs: HashMap<String, Vec<shapelib::Catalogue>>,
}
#[derive(Debug)]
pub struct OutlineCalculable { }
#[derive(Debug)]
-pub struct Contents {
+pub struct Catalogue {
libname: String,
dirname: String,
bundle: Option<bundles::Id>,
}
impl Registry {
- pub fn add(&mut self, data: Contents) {
+ pub fn add(&mut self, data: Catalogue) {
self.libs
.entry(data.libname.clone()).or_default()
.push(data);
self.libs.clear()
}
- pub fn iter(&self) -> impl Iterator<Item=&[Contents]> {
+ pub fn iter(&self) -> impl Iterator<Item=&[Catalogue]> {
self.libs.values().map(|v| v.as_slice())
}
}
}
impl<'ig> AllRegistries<'ig> {
- pub fn all_libs(&self) -> impl Iterator<Item=&[Contents]> {
+ pub fn all_libs(&self) -> impl Iterator<Item=&[Catalogue]> {
self.iter().map(|reg| ®.libs).flatten().map(
|(_libname, lib)| lib.as_slice()
)
}
- pub fn lib_name_lookup(&self, libname: &str) -> Result<&[Contents], SpE> {
+ pub fn lib_name_lookup(&self, libname: &str) -> Result<&[Catalogue], SpE> {
for reg in self.iter() {
if let Some(r) = reg.libs.get(libname) { return Ok(r) }
}
}
}
-impl Contents {
+impl Catalogue {
#[throws(SpecError)]
fn load_image(&self, item_name: &SvgBaseName<str>,
lib_name_for: &str, item_for: &str,
}
#[throws(LibraryLoadError)]
-pub fn load_catalogue(libname: &str, src: &mut dyn LibrarySource) -> Contents {
+pub fn load_catalogue(libname: &str, src: &mut dyn LibrarySource)
+ -> Catalogue {
let toplevel: toml::Value = src.catalogue_data().parse()?;
- let mut l = Contents {
+ let mut l = Catalogue {
bundle: src.bundle(),
libname: libname.to_string(),
items: HashMap::new(),