diff --git a/.taplo.toml b/.taplo.toml new file mode 100644 index 0000000..97b7458 --- /dev/null +++ b/.taplo.toml @@ -0,0 +1,32 @@ +[formatting] +indent_string = "\t" +reorder_keys = false +reorder_arrays = false +reorder_inline_tables = true + +[[rule]] +include = ["**/Cargo.toml"] + +[rule.schema] +path = "https://json.schemastore.org/cargo.json" +enabled = true + +# schema definition for .cargo/config.toml is not yet available +# see https://github.com/rust-lang/cargo/issues/12883 + +[[rule]] +include = ["**/Cargo.toml"] +keys = [ + "build-dependencies", + "dependencies", + "dev-dependencies", + "target.*.build-dependencies", + "target.*.dependencies", + "target.*.dev-dependencies", + "workspace.dependencies", + "workspace.lints.clippy", +] + +[rule.formatting] +reorder_keys = true +reorder_arrays = true diff --git a/Cargo.toml b/Cargo.toml index 71e3710..bd0c352 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,11 +8,12 @@ version = "1.9.9-pre-9" [workspace.lints.clippy] pedantic = "warn" + +cast-possible-truncation = { level = "allow", priority = 1 } +cast-precision-loss = { level = "allow", priority = 1 } +default-trait-access = { level = "allow", priority = 1 } +missing-errors-doc = { level = "allow", priority = 1 } +missing-panics-doc = { level = "allow", priority = 1 } module-name-repetitions = { level = "allow", priority = 1 } struct-excessive-bools = { level = "allow", priority = 1 } too-many-lines = { level = "allow", priority = 1 } -default-trait-access = { level = "allow", priority = 1 } -cast-precision-loss = { level = "allow", priority = 1 } -cast-possible-truncation = { level = "allow", priority = 1 } -missing-errors-doc = { level = "allow", priority = 1 } -missing-panics-doc = { level = "allow", priority = 1 } diff --git a/charge-controller-supervisor/Cargo.toml b/charge-controller-supervisor/Cargo.toml index f56b4a1..c2a3e21 100644 --- a/charge-controller-supervisor/Cargo.toml +++ b/charge-controller-supervisor/Cargo.toml @@ -12,20 +12,20 @@ systemd-units = { enable = false } depends = "" [dependencies] +chrono = "0.4.39" clap = { version = "4.5.23", features = ["derive"] } +env_logger = "0.11.6" +eyre = "0.6.12" +futures = "0.3.31" +lazy_static = "1.5.0" +log = "0.4.22" +prometheus = "0.13.4" +rocket = { version = "0.5.1", features = ["json"] } serde = { version = "1.0.216", features = ["derive"] } serde_json = "1.0.134" tokio = { version = "1.42.0", features = ["full"] } -rocket = { version = "0.5.1", features = ["json"] } -chrono = "0.4.39" -prometheus = "0.13.4" -env_logger = "0.11.6" -log = "0.4.22" -futures = "0.3.31" tokio-modbus = "0.16.1" tokio-serial = "5.4.4" -lazy_static = "1.5.0" -eyre = "0.6.12" [lints] workspace = true diff --git a/charge-controller-supervisor/src/config.rs b/charge-controller-supervisor/src/config.rs index ad202bd..1a4e0b9 100644 --- a/charge-controller-supervisor/src/config.rs +++ b/charge-controller-supervisor/src/config.rs @@ -1,5 +1,18 @@ use serde::{Deserialize, Serialize}; +static CONFIG_PATH: std::sync::OnceLock = std::sync::OnceLock::new(); +pub(super) static CONFIG: std::sync::OnceLock> = + std::sync::OnceLock::new(); + +pub async fn access_config<'a>() -> tokio::sync::RwLockReadGuard<'a, Config> { + CONFIG.get().unwrap().read().await +} + +pub(super) struct ConfigWatcher { + _debouncer: notify_debouncer_mini::Debouncer, + _handle: tokio::task::JoinHandle<()>, +} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)] #[serde(default)] pub struct Config { diff --git a/tesla-charge-controller/Cargo.toml b/tesla-charge-controller/Cargo.toml index 86ad467..c54c093 100644 --- a/tesla-charge-controller/Cargo.toml +++ b/tesla-charge-controller/Cargo.toml @@ -12,30 +12,30 @@ systemd-units = { enable = false } depends = "charge-controller-supervisor" [dependencies] +chrono = "0.4.39" clap = { version = "4.5.23", features = ["derive"] } +env_logger = "0.11.6" +eyre = "0.6.12" +if_chain = "1.0.2" +include_dir = "0.7.4" +lazy_static = "1.5.0" +log = "0.4.22" +notify-debouncer-mini = { version = "0.5.0", default-features = false } +prometheus = "0.13.4" +rand = "0.8.5" +reqwest = { version = "0.12.9", default-features = false, features = [ + "json", + "rustls-tls", +] } +rocket = { version = "0.5.1", features = ["json"] } ron = "0.8.1" serde = { version = "1.0.216", features = ["derive"] } serde_json = "1.0.134" -tokio = { version = "1.42.0", features = ["full"] } -thiserror = "2.0.9" -rocket = { version = "0.5.1", features = ["json"] } -include_dir = "0.7.4" -chrono = "0.4.39" -prometheus = "0.13.4" -env_logger = "0.11.6" -log = "0.4.22" serialport = "4.6.1" +thiserror = "2.0.9" +tokio = { version = "1.42.0", features = ["full"] } tokio-modbus = "0.16.1" tokio-serial = "5.4.4" -if_chain = "1.0.2" -notify-debouncer-mini = { version = "0.5.0", default-features = false } -lazy_static = "1.5.0" -rand = "0.8.5" -reqwest = { version = "0.12.9", default-features = false, features = [ - "rustls-tls", - "json", -] } -eyre = "0.6.12" [lints] workspace = true