game: instance_name.clone(),
hash: bundles::Hash(hash.into()), kind,
};
- chan.cmd_withbulk(&cmd, &mut f, &mut io::sink())?;
+ chan.cmd_withbulk(&cmd, &mut f, &mut io::sink(), &mut |_|Ok((/*todo*/)))?;
}
inventory::submit!{Subcommand(
game: instance_name.clone(),
id,
};
- chan.cmd_withbulk(&cmd, &mut io::empty(), &mut f)
+ chan.cmd_withbulk(&cmd, &mut io::empty(), &mut f, &mut |_| Ok(()))
.context("download bundle")?;
f.flush().context("flush bundle file")?;
if let Some((path, tmp)) = path_tmp {
#[derive(Debug,Serialize,Deserialize)]
pub enum MgmtResponse {
Fine,
+ Progress(ProgressInfo),
Error { error: MgmtError },
AlterGame { error: Option<MgmtError>, responses: Vec<MgmtGameResponse> },
AccountsList(Vec<Arc<AccountName>>),
// RemovePlayer { player: PlayerId }, todo, does a special setacl
}
+#[derive(Debug,Clone,Serialize,Deserialize)]
+pub struct ProgressInfo {
+ count: usize,
+ of: usize,
+}
+
#[derive(Debug,Serialize,Deserialize)]
pub struct MgmtPlayerDetails {
pub nick: Option<String>,
}
#[throws(AE)]
- pub fn cmd_withbulk<U,D>(&mut self, cmd: &MgmtCommand,
- up: &mut U, down: &mut D)
- -> MgmtResponse
- where U: Read, D: Write
+ pub fn cmd_withbulk<U,D,P>(&mut self, cmd: &MgmtCommand,
+ up: &mut U, down: &mut D, progress: &mut P)
+ -> MgmtResponse
+ where U: Read, D: Write,
+ P: FnMut(ProgressInfo) -> Result<(),AE>,
{
use MgmtResponse::*;
let mut wbulk = self.write.write_withbulk(&cmd).context("send command")?;
io::copy(up,&mut wbulk).context("copy bulk upload")?;
wbulk.finish().context("finish sending command and data")?;
- let (resp, mut rbulk)= self.read.read_withbulk().context("read response")?;
+ let (mut resp, mut rbulk) =
+ self.read.read_withbulk()
+ .context("read response")?;
+ while let MR::Progress(pi) = resp {
+ resp = (&mut rbulk).read_rmp()?;
+ progress(pi)?;
+ }
match &resp {
+ Progress(_) => panic!(),
Fine | AccountsList{..} | GamesList{..} |
LibraryItems(_) | Bundles{..} => { },
AlterGame { error: None, .. } => { },
#[throws(AE)]
pub fn cmd(&mut self, cmd: &MgmtCommand) -> MgmtResponse {
- self.cmd_withbulk(cmd, &mut io::empty(), &mut io::sink())?
+ self.cmd_withbulk(cmd, &mut io::empty(), &mut io::sink(), &mut |_|Ok(()))?
}
#[throws(AE)]