let (_ig, auth) = cs.check_acl(&ag, &mut igu, PCH::Instance,
TP_ACCESS_BUNDLES)?;
let bundles = bundles.by(auth);
- MR::Bundles(bundles.list())
+ let bundles = bundles.list();
+ MR::Bundles { bundles }
}
MC::ListGames { all } => {
let resp = chan.cmd(&MC::ListBundles {
game: instance_name.clone(),
})?;
- if_let!{ MR::Bundles(bundles) = resp;
+ if_let!{ MR::Bundles { bundles } = resp;
else throw!(anyhow!("unexpected {:?}", &resp)) };
- for (index, note) in bundles.into_iter().enumerate() {
- if_let!{ Some(note) = note; else continue; }
- println!("{} {:?}", bundles::Index::try_from(index).unwrap(), ¬e);
+ for (id, state) in bundles {
+ println!("{} {:?}", id, &state);
}
}
bundles: Vec<Option<Note>>,
}
-pub type MgmtList = Vec<Option<Note>>;
-
#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct Note {
pub kind: Kind,
impl InstanceBundles {
pub fn new() -> Self { InstanceBundles{ bundles: default() } }
- pub fn list(&self) -> MgmtList { self.bundles.clone() }
+ pub fn list(&self) -> MgmtBundleList {
+ self.bundles.iter().enumerate().filter_map(|(index, slot)| {
+ let note = slot.as_ref()?;
+ let index = index.try_into().unwrap();
+ Some((Id { index, kind: note.kind },
+ note.state.clone()))
+ }).collect()
+ }
#[throws(IE)]
pub fn load_game_bundles(ig: &mut Instance) -> Self {
AccountsList(Vec<Arc<AccountName>>),
GamesList(Vec<Arc<InstanceName>>),
LibraryItems(Vec<shapelib::ItemEnquiryData>),
- Bundles(bundles::MgmtList),
+ Bundles { bundles: MgmtBundleList },
}
+pub type MgmtBundleList = BTreeMap<bundles::Id, bundles::State>;
+
#[derive(Debug,Serialize,Deserialize)]
pub enum MgmtGameInstruction {
Noop,
let (resp, mut rbulk)= self.read.read_withbulk().context("read response")?;
match &resp {
Fine | AccountsList{..} | GamesList{..} |
- LibraryItems(_) | Bundles(..) => { },
+ LibraryItems(_) | Bundles{..} => { },
AlterGame { error: None, .. } => { },
Error { error } => {
Err(error.clone()).context(
pub use crate::commands::{AccessTokenInfo, AccessTokenReport, MgmtError};
pub use crate::commands::{MgmtCommand, MgmtResponse};
pub use crate::commands::{MgmtGameInstruction, MgmtGameResponse};
-pub use crate::commands::{MgmtGameUpdateMode};
+pub use crate::commands::{MgmtBundleList, MgmtGameUpdateMode};
pub use crate::config::*;
pub use crate::debugreader::DebugReader;
pub use crate::error::*;