Fine
}
+ MC::LibraryListLibraries { game } => {
+ let (ag, gref) = start_access_game(&game)?;
+ let (libs, _auth) =
+ access_bundles(
+ cs,&ag,&gref, &[TP::UploadBundles],
+ &mut |ig, _| Ok(
+ ig.all_shapelibs()
+ .iter()
+ .map(|reg| reg.iter())
+ .flatten()
+ .map(|ll| ll.iter())
+ .flatten()
+ .map(|l| l.enquiry())
+ .collect::<Vec<shapelib::LibraryEnquiryData>>()
+ )
+ )?;
+ MR::Libraries(libs)
+ }
+
MC::LibraryListByGlob { game, glob: spec } => {
let (ag, gref) = start_access_game(&game)?;
let (results, _auth) =
id: bundles::Id,
},
+ LibraryListLibraries {
+ game: InstanceName,
+ },
LibraryListByGlob {
game: InstanceName,
glob: shapelib::ItemSpec,
AlterGame { error: Option<MgmtError>, responses: Vec<MgmtGameResponse> },
AccountsList(Vec<Arc<AccountName>>),
GamesList(Vec<Arc<InstanceName>>),
+ Libraries(Vec<shapelib::LibraryEnquiryData>),
LibraryItems(Vec<shapelib::ItemEnquiryData>),
Bundles { bundles: MgmtBundleList },
}
match &resp {
Progress(_) => panic!(),
Fine | AccountsList{..} | GamesList{..} |
- LibraryItems(_) | Bundles{..} => { },
+ Libraries(_) | LibraryItems(_) | Bundles{..} => { },
AlterGame { error: None, .. } => { },
Error { error } => {
Err(error.clone()).context(
}
}
+#[derive(Debug,Clone,Serialize,Deserialize,Eq,PartialEq,Ord,PartialOrd)]
+pub struct LibraryEnquiryData {
+ pub libname: String,
+}
+impl Display for LibraryEnquiryData {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut Formatter) {
+ if self.libname.chars().all(|c| {
+ c.is_alphanumeric() || c=='-' || c=='_' || c=='.'
+ }) {
+ Display::fmt(&self.libname, f)?;
+ } else {
+ Debug::fmt(&self.libname, f)?;
+ }
+ }
+}
+
#[dyn_upcast]
impl OutlineTrait for Item { delegate! { to self.outline {
fn outline_path(&self, scale: f64) -> Result<Html, IE>;
pub fn clear(&mut self) {
self.libs.clear()
}
+
+ pub fn iter(&self) -> impl Iterator<Item=&[Contents]> {
+ self.libs.values().map(|v| v.as_slice())
+ }
}
pub struct AllRegistries<'ig> {
}
impl<'ig> AllRegistries<'ig> {
+ pub fn all_libs(&self) -> impl Iterator<Item=&[Contents]> {
+ self.iter().map(|reg| ®.libs).flatten().map(
+ |(_libname, lib)| lib.as_slice()
+ )
+ }
pub fn lib_name_lookup(&self, libname: &str) -> Result<&[Contents], SpE> {
for reg in self.iter() {
if let Some(r) = reg.libs.get(libname) { return Ok(r) }
(Box::new(it), occultable)
}
+ pub fn enquiry(&self) -> LibraryEnquiryData {
+ LibraryEnquiryData {
+ libname: self.libname.clone(),
+ }
+ }
+
#[throws(MgmtError)]
pub fn list_glob(&self, pat: &str) -> Vec<ItemEnquiryData> {
let pat = glob::Pattern::new(pat).map_err(|pe| ME::BadGlob {