comparison rust/src/params.rs @ 635:4424a8b30f9c rust

config crate wants everything to be lower case
author Matt Johnston <matt@ucc.asn.au>
date Sun, 22 Sep 2019 22:06:46 +0800
parents a5721c02d3ee
children 43eb3cfdf769
comparison
equal deleted inserted replaced
634:a5721c02d3ee 635:4424a8b30f9c
58 File::open(filename)?.read_to_string(&mut s)?; 58 File::open(filename)?.read_to_string(&mut s)?;
59 Ok(serde_json::from_str(&s)?) 59 Ok(serde_json::from_str(&s)?)
60 } 60 }
61 61
62 pub fn load(config: &Config) -> Params { 62 pub fn load(config: &Config) -> Params {
63 Self::try_load(&config.PARAMS_FILE) 63 Self::try_load(&config.params_file)
64 .unwrap_or_else(|_| Params::defaults()) 64 .unwrap_or_else(|_| Params::defaults())
65 } 65 }
66 66
67 } 67 }
68 68
146 }, 146 },
147 } 147 }
148 } 148 }
149 149
150 fn write_params(&self, params: &Params) { 150 fn write_params(&self, params: &Params) {
151 let p = atomicwrites::AtomicFile::new(&self.config.PARAMS_FILE, atomicwrites::AllowOverwrite); 151 let p = atomicwrites::AtomicFile::new(&self.config.params_file, atomicwrites::AllowOverwrite);
152 p.write(|f| { 152 p.write(|f| {
153 serde_json::to_writer(f, params) 153 serde_json::to_writer(f, params)
154 }); 154 });
155 } 155 }
156 156
157 fn do_poll(&mut self, ctx: &Context<<Self as Actor>::Msg>) -> Result<(), TemplogError> { 157 fn do_poll(&mut self, ctx: &Context<<Self as Actor>::Msg>) -> Result<(), TemplogError> {
158 let url = self.config.SETTINGS_URL.clone(); 158 let url = self.config.settings_url.clone();
159 let etag = self.last_etag.borrow().clone(); 159 let etag = self.last_etag.borrow().clone();
160 let h = ctx.run(async move { 160 let h = ctx.run(async move {
161 Self::wait_updates(&url, &etag).await 161 Self::wait_updates(&url, &etag).await
162 }).expect("spawn failed"); // XXX error handling 162 }).expect("spawn failed"); // XXX error handling
163 let (chunk, stat) = block_on(h)?; 163 let (chunk, stat) = block_on(h)?;