use strafesnet_snf::bot::BotDebug; pub enum Instruction{ //TODO: pass map id Create, Delete, Push{ ins:strafesnet_common::instruction::TimedInstruction, }, } //a new worker is spawned on a thread //create opens a new file //push pushes an instruction to the file pub struct Worker{ file:Option, } pub fn new<'a>(scope:&'a std::thread::Scope<'a,'_>)->crate::worker::QNWorker<'a,Instruction>{ let mut worker=Worker{ file:None, }; crate::worker::QNWorker::new(scope,move|instruction|{ match instruction{ Instruction::Create=>{ worker.file=Some(BotDebug::new().unwrap()) }, Instruction::Delete=>{ match worker.file.take(){ Some(file)=>file.delete().unwrap(), None=>println!("no file created!"), } } Instruction::Push{ins}=>{ match &mut worker.file{ Some(file)=>file.push(ins).unwrap(), None=>println!("no file created!"), } }, } }) }