pass clippy
This commit is contained in:
@@ -9,11 +9,9 @@ pub fn read_env_var() {
|
|||||||
fs::read_to_string(path).expect("Something went wrong reading the file : device.env");
|
fs::read_to_string(path).expect("Something went wrong reading the file : device.env");
|
||||||
|
|
||||||
if let Ok(lines) = read_lines(path) {
|
if let Ok(lines) = read_lines(path) {
|
||||||
for line in lines {
|
for var in lines.map_while(Result::ok) {
|
||||||
if let Ok(var) = line {
|
let new_var: Vec<&str> = var.split('=').collect();
|
||||||
let new_var: Vec<&str> = var.split('=').collect();
|
env::set_var(new_var[0], new_var[1]);
|
||||||
env::set_var(new_var[0], new_var[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ pub fn get_topic_name(types: &str) -> String {
|
|||||||
let capteur = env::var("CAPTEUR").unwrap().to_string();
|
let capteur = env::var("CAPTEUR").unwrap().to_string();
|
||||||
topic.push_str(&capteur);
|
topic.push_str(&capteur);
|
||||||
topic.push('/');
|
topic.push('/');
|
||||||
topic.push_str(&types);
|
topic.push_str(types);
|
||||||
|
|
||||||
topic
|
topic
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub fn get_temperature() -> f32 {
|
|||||||
|
|
||||||
let temperature_string = &String::from_utf8_lossy(&temperature_command.stdout)[..5];
|
let temperature_string = &String::from_utf8_lossy(&temperature_command.stdout)[..5];
|
||||||
temperature = temperature_string.parse::<f32>().unwrap();
|
temperature = temperature_string.parse::<f32>().unwrap();
|
||||||
temperature = temperature / 1000.0;
|
temperature /= 1000.0;
|
||||||
} else {
|
} else {
|
||||||
let temperature_command = Command::new("sudo")
|
let temperature_command = Command::new("sudo")
|
||||||
.arg("/opt/vc/bin/vcgencmd")
|
.arg("/opt/vc/bin/vcgencmd")
|
||||||
@@ -39,9 +39,8 @@ pub fn get_storage() -> i8 {
|
|||||||
let vec_storage: Vec<&str> = storage_string.split_whitespace().collect();
|
let vec_storage: Vec<&str> = storage_string.split_whitespace().collect();
|
||||||
let mut value = vec_storage[vec_storage.len() - 2].to_string();
|
let mut value = vec_storage[vec_storage.len() - 2].to_string();
|
||||||
value.pop();
|
value.pop();
|
||||||
let storage = value.parse::<i8>().unwrap();
|
|
||||||
|
|
||||||
storage
|
value.parse::<i8>().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_mem() -> i8 {
|
pub fn get_mem() -> i8 {
|
||||||
@@ -54,9 +53,8 @@ pub fn get_mem() -> i8 {
|
|||||||
let vec_mem: Vec<&str> = mem_string.split_whitespace().collect();
|
let vec_mem: Vec<&str> = mem_string.split_whitespace().collect();
|
||||||
let total = vec_mem[7].parse::<f32>().unwrap();
|
let total = vec_mem[7].parse::<f32>().unwrap();
|
||||||
let mem_use = vec_mem[8].parse::<f32>().unwrap();
|
let mem_use = vec_mem[8].parse::<f32>().unwrap();
|
||||||
let result = (mem_use / total * 100.0) as i8;
|
|
||||||
|
|
||||||
result
|
(mem_use / total * 100.0) as i8
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_battery() -> i8 {
|
pub fn get_battery() -> i8 {
|
||||||
@@ -70,7 +68,7 @@ pub fn get_battery() -> i8 {
|
|||||||
.unwrap_or_else(|e| panic!("failed to execute process: {}", e));
|
.unwrap_or_else(|e| panic!("failed to execute process: {}", e));
|
||||||
|
|
||||||
let battery_string = &String::from_utf8_lossy(&battery_command.stdout);
|
let battery_string = &String::from_utf8_lossy(&battery_command.stdout);
|
||||||
battery = (&battery_string[..battery_string.len() - 1])
|
battery = (battery_string[..battery_string.len() - 1])
|
||||||
.parse::<i8>()
|
.parse::<i8>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user