Update backend code to Rust Edition 2024
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use crate::app_config::{AppConfig, ConsumptionBackend};
|
||||
use rand::{thread_rng, Rng};
|
||||
use rand::{Rng, rng};
|
||||
use std::num::ParseIntError;
|
||||
use std::path::Path;
|
||||
|
||||
@ -49,7 +49,7 @@ pub async fn get_curr_consumption() -> anyhow::Result<EnergyConsumption> {
|
||||
match backend {
|
||||
ConsumptionBackend::Constant { value } => Ok(*value),
|
||||
|
||||
ConsumptionBackend::Random { min, max } => Ok(thread_rng().gen_range(*min..*max)),
|
||||
ConsumptionBackend::Random { min, max } => Ok(rng().random_range(*min..*max)),
|
||||
|
||||
ConsumptionBackend::File { path } => {
|
||||
let path = Path::new(path);
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::app_config::AppConfig;
|
||||
use prettytable::{row, Table};
|
||||
use prettytable::{Table, row};
|
||||
|
||||
use crate::constants;
|
||||
use crate::devices::device::{Device, DeviceId, DeviceRelay, DeviceRelayID};
|
||||
@ -289,7 +289,11 @@ impl EnergyEngine {
|
||||
continue;
|
||||
}
|
||||
|
||||
log::info!("Forcefully turn on relay {} to catch up running constraints (only {}s this day)", r.name, total_runtime);
|
||||
log::info!(
|
||||
"Forcefully turn on relay {} to catch up running constraints (only {}s this day)",
|
||||
r.name,
|
||||
total_runtime
|
||||
);
|
||||
new_relays_state.get_mut(&r.id).unwrap().on = true;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ pub fn relay_total_runtime_adjusted(relay: &DeviceRelay) -> usize {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::devices::device::DeviceRelayID;
|
||||
use crate::energy::relay_state_history::{relay_total_runtime, RelayStateHistory};
|
||||
use crate::energy::relay_state_history::{RelayStateHistory, relay_total_runtime};
|
||||
|
||||
#[test]
|
||||
fn test_relay_state_history() {
|
||||
|
Reference in New Issue
Block a user