comparison rust/src/config.rs @ 597:a440eafa84a9 rust

progress for debug
author Matt Johnston <matt@ucc.asn.au>
date Sat, 07 Jan 2017 00:56:39 +0800
parents ca8102feaca6
children d4fbfb5c46ff
comparison
equal deleted inserted replaced
596:ca8102feaca6 597:a440eafa84a9
3 use serde::Serialize; 3 use serde::Serialize;
4 4
5 #[derive(Deserialize,Serialize,Debug,Clone)] 5 #[derive(Deserialize,Serialize,Debug,Clone)]
6 #[allow(non_snake_case)] 6 #[allow(non_snake_case)]
7 pub struct Config { 7 pub struct Config {
8 pub FRIDGE_SLEEP: u64,
9 pub SENSOR_SLEEP: u64, 8 pub SENSOR_SLEEP: u64,
10 pub UPLOAD_SLEEP: u64, 9 pub UPLOAD_SLEEP: u64,
11 10
12 pub FRIDGE_DELAY: u64, 11 pub FRIDGE_DELAY: u64,
13 pub FRIDGE_WORT_INVALID_TIME: u64, 12 pub FRIDGE_WORT_INVALID_TIME: u64,
66 pub fn to_toml_string(&self) -> String { 65 pub fn to_toml_string(&self) -> String {
67 let mut e = toml::Encoder::new(); 66 let mut e = toml::Encoder::new();
68 self.serialize(&mut e).unwrap(); 67 self.serialize(&mut e).unwrap();
69 toml::Value::Table(e.toml).to_string() 68 toml::Value::Table(e.toml).to_string()
70 } 69 }
70
71 /*
72 pub fn parse(&mut self, s: &str) {
73 let filename = "tempserver.conf";
74
75 let f = File::open(filename)
76 .map_err(|e| e.to_string())
77 .and_then(|mut f| {
78 let mut s = String::new();
79 f.read_to_string(&mut s)
80 .map_err(|e| e.to_string())
81 .map(|_| s)
82 })
83 .and_then(|s| {
84
85 .map_err(|e| e.to_string())
86 });
87
88 match f {
89 Ok() => {
90
91 },
92 Err(e) => {
93 debug!("Error loading config file {}: {}",
94 filename, e);
95
96 }
97 }
98
99 }
100 */
71 } 101 }