From ffd163504532d08769c3357f85e33e2e62d83a6e Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Tue, 24 Mar 2026 19:59:02 +0900 Subject: [PATCH] first commit --- .cspell.json | 27 + .gitignore | 6 + .prettierrc.json | 8 + .vscode/extensions.json | 7 + .vscode/settings.json | 18 + AGENTS.md | 66 + Cargo.lock | 1984 +++++++++++++++++++++++++++++ Cargo.toml | 12 + LICENSE | 21 + README.md | 153 +++ crates/core/Cargo.toml | 11 + crates/core/src/config.rs | 196 +++ crates/core/src/digitemp.rs | 74 ++ crates/core/src/lib.rs | 5 + crates/core/src/mail.rs | 89 ++ crates/core/src/rrd.rs | 279 ++++ crates/core/src/template.rs | 42 + db/.gitkeep | 0 etc/crontab.sample | 9 + etc/digitemp-rrdgraph.sample.json | 25 + etc/digitemp.sample.conf | 9 + html/css/default.css | 27 + html/css/logo.png | Bin 0 -> 3144 bytes html/images/.gitkeep | 0 src/commands.rs | 3 + src/commands/check_alert.rs | 52 + src/commands/send_info.rs | 44 + src/commands/update.rs | 52 + src/main.rs | 174 +++ templates/index.tera | 72 ++ templates/mail_alert.tera | 14 + templates/mail_info.tera | 9 + templates/mail_sensor.inc.tera | 6 + 33 files changed, 3494 insertions(+) create mode 100644 .cspell.json create mode 100644 .gitignore create mode 100644 .prettierrc.json create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 AGENTS.md create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 crates/core/Cargo.toml create mode 100644 crates/core/src/config.rs create mode 100644 crates/core/src/digitemp.rs create mode 100644 crates/core/src/lib.rs create mode 100644 crates/core/src/mail.rs create mode 100644 crates/core/src/rrd.rs create mode 100644 crates/core/src/template.rs create mode 100644 db/.gitkeep create mode 100644 etc/crontab.sample create mode 100644 etc/digitemp-rrdgraph.sample.json create mode 100644 etc/digitemp.sample.conf create mode 100644 html/css/default.css create mode 100644 html/css/logo.png create mode 100644 html/images/.gitkeep create mode 100644 src/commands.rs create mode 100644 src/commands/check_alert.rs create mode 100644 src/commands/send_info.rs create mode 100644 src/commands/update.rs create mode 100644 src/main.rs create mode 100644 templates/index.tera create mode 100644 templates/mail_alert.tera create mode 100644 templates/mail_info.tera create mode 100644 templates/mail_sensor.inc.tera diff --git a/.cspell.json b/.cspell.json new file mode 100644 index 0000000..92a1530 --- /dev/null +++ b/.cspell.json @@ -0,0 +1,27 @@ +{ + "version": "0.2", + "language": "en, en-US, en-GB", + "ignorePaths": [], + "dictionaryDefinitions": [], + "dictionaries": [], + "words": [ + "digitemp", + "GPRINT", + "imgformat", + "lettre", + "Neuroinformatics", + "RIKEN", + "rrdgraph", + "rrdtemp", + "rrdtool", + "serde", + "smtps", + "starttls", + "tera" + ], + "ignoreWords": [], + "import": [], + "files": [ + "**/*.{rs,twig,conf,html,md,json}" + ] +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f4bc2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/target +/etc/digitemp-rrdgraph.json +/etc/digitemp.conf +/html/index.html +/html/images/graph-*.png +/db/*.rrd \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..c81dab1 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://json.schemastore.org/prettierrc", + "semi": true, + "tabWidth": 2, + "singleQuote": true, + "printWidth": 120, + "trailingComma": "es5" +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..c96124c --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "1yib.rust-bundle", + "streetsidesoftware.code-spell-checker", + "esbenp.prettier-vscode" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d47f8c5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,18 @@ +{ + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + // Extensions - Biome + "biome.enabled": false + // Extensions - Code Spell Checker + // - see: .cspell.json + // Extensions - Prettier + // - see: .prettierrc.json +} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..772ed30 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,66 @@ +# AGENTS.md + +## Scope + +This file applies to the Rust workspace at `digitemp-rrdgraph/`. + +## Project Summary + +- The binary provides three operational subcommands: `update`, `check-alert`, and `send-info`. +- The repository is a Cargo workspace with a CLI crate at the repository root and an internal library crate at `crates/core/` named `digitemp_rrdgraph_core`. +- The system depends on external commands and resources: `digitemp`, `rrdtool`, SMTP, JSON config files under `etc/`, Tera templates under `templates/`, generated graphs under `html/images/`, and RRD files under `db/`. + +## Source Of Truth + +- Treat this Rust repository as the sole implementation and documentation target. +- Preserve the CLI contract exposed by `src/main.rs`, the command modules under `src/commands/`, and the public interfaces exposed by `crates/core/src/lib.rs` unless the user explicitly requests a behavior change. +- Preserve the configuration schema in `etc/config.sample.json` unless the user explicitly asks for a breaking change. +- Preserve template variable names expected by `templates/*.tera` unless the templates are updated in the same change. + +## Documentation And Language + +- Write repository documentation such as `AGENTS.md`, `README.md`, and other project documents in English by default. +- When adding comments to source code, configuration files, templates, or scripts, write those comments in English. +- Keep user-facing configuration keys, template names, and command names stable unless the task explicitly requires a change. + +## Change Priorities + +- Prefer fixes at the behavior or interface boundary, not cosmetic refactors. +- Keep CLI behavior and config keys stable. +- Keep changes small and local to the affected command or library module. +- Avoid introducing new crates unless the standard library or existing dependencies are clearly insufficient. +- Prefer explicit error propagation with `Result` over `unwrap` or `expect` in runtime paths. + +## Safe Editing Rules + +- Do not edit generated or runtime data under `target/`, `db/`, or `html/images/` unless the task explicitly requires it. +- Do not overwrite `etc/digitemp-rrdgraph.conf` for convenience; use `etc/config.sample.json` as the editable reference. +- Be careful with commands that can talk to real hardware, modify RRD files, or send email. +- When validation would invoke external systems, prefer build-only or isolated checks unless the user explicitly wants end-to-end execution. + +## Validation Expectations + +- After Rust code changes, run `cargo build` in this repository at minimum. Prefer `cargo build --workspace` when changes affect `crates/core/` or workspace wiring. +- If you add or refactor logic that can be unit tested without hardware or SMTP, add focused tests and run them. +- Prefer tests around pure logic such as config parsing, digitemp config parsing, template rendering, and any command-argument construction helpers. +- If a change depends on hardware access or local services, state clearly what could not be verified. + +## Implementation Guidance + +- Keep path handling relative to the repository root unless a config field explicitly stores an absolute path. +- Encapsulate shell command construction so it can be inspected or tested without executing the command. +- Match existing naming and module boundaries under `src/commands/` and `crates/core/src/`. +- Keep CLI-only orchestration in the root crate and reusable logic in `digitemp_rrdgraph_core`. +- Prefer direct, maintainable implementations over compatibility layers or unnecessary abstraction. + +## Useful References + +- Rust entrypoint: `src/main.rs` +- Rust commands: `src/commands/` +- Internal library crate manifest: `crates/core/Cargo.toml` +- Rust support modules: `crates/core/src/` +- Sample config: `etc/config.sample.json` +- Email templates: `templates/` +- RRD files: `db/` +- Graph images: `html/images/` +- External dependencies: `digitemp`, `rrdtool`, SMTP server diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d71f104 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1984 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "ar_archive_writer" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb93bbb63b9c227414f6eb3a0adfddca591a8ce1e9b60661bb08969b87e340b" +dependencies = [ + "object", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bstr" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "cc" +version = "1.2.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "chrono-tz" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" +dependencies = [ + "chrono", + "chrono-tz-build", + "phf", +] + +[[package]] +name = "chrono-tz-build" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" +dependencies = [ + "parse-zoneinfo", + "phf", + "phf_codegen", +] + +[[package]] +name = "chumsky" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eebd66744a15ded14960ab4ccdbfb51ad3b81f51f3f04a80adac98c985396c9" +dependencies = [ + "hashbrown 0.14.5", + "stacker", +] + +[[package]] +name = "clap" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "deunicode" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abd57806937c9cc163efc8ea3910e00a62e2aeb0b8119f1793a978088f8f6b04" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "digitemp-rrdgraph" +version = "0.1.0" +dependencies = [ + "clap", + "digitemp_rrdgraph_core", + "serde_json", +] + +[[package]] +name = "digitemp_rrdgraph_core" +version = "0.1.0" +dependencies = [ + "chrono", + "lettre", + "serde", + "serde_json", + "tera", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "email-encoding" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9298e6504d9b9e780ed3f7dfd43a61be8cd0e09eb07f7706a945b0072b6670b6" +dependencies = [ + "base64", + "memchr", +] + +[[package]] +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "globset" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "globwalk" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" +dependencies = [ + "bitflags", + "ignore", + "walkdir", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hostname" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd" +dependencies = [ + "cfg-if", + "libc", + "windows-link", +] + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "humansize" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" +dependencies = [ + "libm", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "ignore" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3d782a365a015e0f5c04902246139249abf769125006fbe7649e2ee88169b4a" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "lettre" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e13e10e8818f8b2a60f52cb127041d388b89f3a96a62be9ceaffa22262fef7f" +dependencies = [ + "base64", + "chumsky", + "email-encoding", + "email_address", + "fastrand", + "futures-util", + "hostname", + "httpdate", + "idna", + "mime", + "native-tls", + "nom", + "percent-encoding", + "quoted_printable", + "socket2", + "tokio", + "url", +] + +[[package]] +name = "libc" +version = "0.2.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "openssl" +version = "0.10.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parse-zoneinfo" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24" +dependencies = [ + "regex", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pest" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" +dependencies = [ + "memchr", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" +dependencies = [ + "pest", + "sha2", +] + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3852766467df634d74f0b2d7819bf8dc483a0eb2e3b0f50f756f9cfe8b0d18d8" +dependencies = [ + "ar_archive_writer", + "cc", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "quoted_printable" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478e0585659a122aa407eb7e3c0e1fa51b1d8a870038bd29f0cf4a8551eea972" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "siphasher" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "slug" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882a80f72ee45de3cc9a5afeb2da0331d58df69e4e7d8eeb5d3c7784ae67e724" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stacker" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d74a23609d509411d10e2176dc2a4346e3b4aea2e7b1869f19fdedbc71c013" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys 0.59.0", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.2", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tera" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8004bca281f2d32df3bacd59bc67b312cb4c70cea46cbd79dbe8ac5ed206722" +dependencies = [ + "chrono", + "chrono-tz", + "globwalk", + "humansize", + "lazy_static", + "percent-encoding", + "pest", + "pest_derive", + "rand", + "regex", + "serde", + "serde_json", + "slug", + "unicode-segmentation", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +dependencies = [ + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.61.2", +] + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbb2a062be311f2ba113ce66f697a4dc589f85e78a4aea276200804cea0ed87" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e8bc7269b54418e7aeeef514aa68f8690b8c0489a06b0136e5f57c4c5ccab89" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e2c4995 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "digitemp-rrdgraph" +version = "0.1.0" +edition = "2024" + +[workspace] +members = ["crates/core"] + +[dependencies] +serde_json = "1.0" +clap = { version = "4.5", features = ["derive"] } +digitemp_rrdgraph_core = { path = "crates/core" } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..403a7d7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Neuroinformatics Unit, RIKEN Center for Brain Science + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4f402a1 --- /dev/null +++ b/README.md @@ -0,0 +1,153 @@ +# digitemp-rrdgraph-rust + +digitemp-rrdgraph-rust is a command-line application for temperature monitoring with 1-Wire sensors. It collects measurements through `digitemp`, stores them in RRD files, generates graph images, and sends email notifications based on configured schedules and thresholds. + +The repository is organized as a Cargo workspace with two crates: + +- `digitemp-rrdgraph`: the CLI binary crate +- `digitemp_rrdgraph_core`: the internal library crate used by the CLI commands + +## Features + +- Read temperature data from 1-Wire sensors through `digitemp` +- Store time-series data in RRD files +- Generate graph images for hourly, daily, weekly, monthly, and yearly views +- Send periodic information emails and threshold-based alert emails +- Configure runtime behavior through JSON and template files + +## Requirements + +- Rust toolchain compatible with edition 2024 +- [digitemp](https://www.digitemp.com/) +- [RRDTool](https://oss.oetiker.ch/rrdtool/) +- Access to an SMTP server for email delivery + +## Project Layout + +- `Cargo.toml`: workspace root and CLI package definition +- `src/`: CLI entrypoint and command modules +- `crates/core/`: internal library crate shared by the CLI commands +- `crates/core/src/`: shared modules for config loading, DigiTemp access, RRD operations, mail sending, and template rendering +- `etc/`: configuration files and cron examples +- `templates/`: Tera mail templates +- `db/`: RRD database files +- `html/images/`: generated graph images + +## Setup + +1. Build the release binary. + +```sh +cargo build --release +``` + +2. Choose where to place the application configuration file. + +You can always override the default search order with `--config /path/to/digitemp-rrdgraph.json`. + +Recommended locations are checked in this order: + +- `$HOME/.config/digitemp-rrdgraph.json` +- `/etc/digitemp-rrdgraph.json` +- `/etc/digitemp-rrdgraph.json` +- `$PWD/etc/digitemp-rrdgraph.json` + +For an installed layout such as `/opt/digitemp-rrdgraph/bin/digitemp-rrdgraph`, place the file at `/opt/digitemp-rrdgraph/etc/digitemp-rrdgraph.json`. + +For local development from the repository root, create `etc/digitemp-rrdgraph.json`. + +```sh +cp etc/digitemp-rrdgraph.sample.json etc/digitemp-rrdgraph.json +``` + +3. Create a DigiTemp configuration file. + +```sh +digitemp_DS9097U -i -s /dev/ttyUSB0 -c ./etc/digitemp.conf +``` + +4. Edit the selected `digitemp-rrdgraph.json` file for your environment. + +Pass `--verbose` if you want the CLI to print the selected configuration file path to standard error. + +Configure at least these values: + +- `digitemp` and `digitemp_config` +- `database_dir` and `images_dir` +- `templates_dir` +- `room_name` +- SMTP server settings +- mail recipients, subjects, and alert thresholds + +`room_name` is required. It is used in mail templates, graph titles, and the generated top page. +The `update` command also regenerates `html/index.html` from the template so the page title and heading stay aligned with `room_name`. + +SMTP settings support these combinations: + +- `mail_smtp_security`: `smtp`, `starttls`, or `smtps` +- `mail_smtp_auth`: `true` to send SMTP AUTH credentials, `false` for unauthenticated servers +- `mail_smtp_username` and `mail_smtp_password`: required only when `mail_smtp_auth` is `true` + +## Build + +```sh +cargo build --release +``` + +This builds both workspace members, including the internal `digitemp_rrdgraph_core` crate. + +The release binary is written to `target/release/digitemp-rrdgraph`. + +To build only the CLI package explicitly: + +```sh +cargo build --release -p digitemp-rrdgraph +``` + +To run tests across the workspace: + +```sh +cargo test --workspace +``` + +## Commands + +The application provides these subcommands: + +- `update`: read sensors, update RRD files, and regenerate graph images +- `check-alert`: evaluate current data against configured alert thresholds and send an alert email when required +- `send-info`: send a periodic information email + +Examples: + +```sh +./target/release/digitemp-rrdgraph update +./target/release/digitemp-rrdgraph --verbose update +./target/release/digitemp-rrdgraph --config /opt/digitemp-rrdgraph/etc/digitemp-rrdgraph.json update +./target/release/digitemp-rrdgraph check-alert +./target/release/digitemp-rrdgraph send-info +``` + +## Scheduling + +Use cron or another scheduler to run the subcommands at appropriate intervals. + +- Run `update` on the data collection interval you want to keep in RRD. +- Run `send-info` on the reporting interval you want for periodic summaries. +- Run `check-alert` on the alert polling interval you want for threshold checks. + +See `etc/crontab.sample` for a sample schedule. + +## Templates + +Mail templates are stored in `templates/` and rendered with [Tera](https://tera.netlify.app/). + +## Development Notes + +- CLI subcommands live under `src/commands/`. +- Shared application logic lives under `crates/core/src/` and is exposed by the `digitemp_rrdgraph_core` crate. +- The root crate depends on the internal core crate through a local path dependency. + +## License + +MIT diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml new file mode 100644 index 0000000..7dec12d --- /dev/null +++ b/crates/core/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "digitemp_rrdgraph_core" +version = "0.1.0" +edition = "2024" + +[dependencies] +chrono = "0.4.44" +lettre = { version = "0.11", features = ["smtp-transport", "builder"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +tera = "1.19" diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs new file mode 100644 index 0000000..080d604 --- /dev/null +++ b/crates/core/src/config.rs @@ -0,0 +1,196 @@ +use serde::Deserialize; +use std::fs; +use std::path::Path; + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum MailSmtpSecurity { + Smtp, + #[default] + Starttls, + Smtps, +} + +fn default_mail_smtp_auth() -> bool { + true +} + +#[derive(Debug, Deserialize)] +pub struct Config { + pub url: String, + pub digitemp: String, + pub digitemp_config: String, + pub database_dir: String, + pub images_dir: String, + pub templates_dir: String, + pub room_name: String, + pub mail_alert_upper: f64, + pub mail_alert_lower: f64, + pub mail_from: String, + pub mail_from_name: String, + pub mail_info_to: String, + pub mail_info_subject: String, + pub mail_info_template: String, + pub mail_alert_to: String, + pub mail_alert_subject: String, + pub mail_alert_template: String, + pub mail_smtp_server: String, + pub mail_smtp_port: u16, + #[serde(default)] + pub mail_smtp_security: MailSmtpSecurity, + #[serde(default = "default_mail_smtp_auth")] + pub mail_smtp_auth: bool, + #[serde(default)] + pub mail_smtp_username: String, + #[serde(default)] + pub mail_smtp_password: String, +} + +#[cfg(test)] +mod tests { + use super::{Config, MailSmtpSecurity}; + + #[test] + fn config_defaults_smtp_security_and_auth() { + let json = r#"{ + "url": "https://example.com/temperature/", + "digitemp": "/bin/digitemp_DS9097U", + "digitemp_config": "etc/digitemp.conf", + "database_dir": "db", + "images_dir": "html/images", + "templates_dir": "templates", + "room_name": "S108", + "mail_alert_upper": 30, + "mail_alert_lower": 17, + "mail_from": "from@example.com", + "mail_from_name": "Temperature Monitor", + "mail_info_to": "info@example.com", + "mail_info_subject": "Info", + "mail_info_template": "mail_info.tera", + "mail_alert_to": "alert@example.com", + "mail_alert_subject": "Alert", + "mail_alert_template": "mail_alert.tera", + "mail_smtp_server": "localhost", + "mail_smtp_port": 587, + "mail_smtp_username": "user@example.com", + "mail_smtp_password": "password" + }"#; + + let config: Config = serde_json::from_str(json).unwrap(); + + assert!(matches!(config.mail_smtp_security, MailSmtpSecurity::Starttls)); + assert!(config.mail_smtp_auth); + assert_eq!(config.room_name().unwrap(), "S108"); + } + + #[test] + fn config_accepts_plain_smtp_without_auth() { + let json = r#"{ + "url": "https://example.com/temperature/", + "digitemp": "/bin/digitemp_DS9097U", + "digitemp_config": "etc/digitemp.conf", + "database_dir": "db", + "images_dir": "html/images", + "templates_dir": "templates", + "room_name": "S108", + "mail_alert_upper": 30, + "mail_alert_lower": 17, + "mail_from": "from@example.com", + "mail_from_name": "Temperature Monitor", + "mail_info_to": "info@example.com", + "mail_info_subject": "Info", + "mail_info_template": "mail_info.tera", + "mail_alert_to": "alert@example.com", + "mail_alert_subject": "Alert", + "mail_alert_template": "mail_alert.tera", + "mail_smtp_server": "localhost", + "mail_smtp_port": 25, + "mail_smtp_security": "smtp", + "mail_smtp_auth": false + }"#; + + let config: Config = serde_json::from_str(json).unwrap(); + + assert!(matches!(config.mail_smtp_security, MailSmtpSecurity::Smtp)); + assert!(!config.mail_smtp_auth); + assert!(config.mail_smtp_username.is_empty()); + assert!(config.mail_smtp_password.is_empty()); + assert_eq!(config.room_name().unwrap(), "S108"); + } + + #[test] + fn room_name_rejects_blank_values() { + let json = r#"{ + "url": "https://example.com/temperature/", + "digitemp": "/bin/digitemp_DS9097U", + "digitemp_config": "etc/digitemp.conf", + "database_dir": "db", + "images_dir": "html/images", + "templates_dir": "templates", + "room_name": " ", + "mail_alert_upper": 30, + "mail_alert_lower": 17, + "mail_from": "from@example.com", + "mail_from_name": "C407 温度監視プログラム", + "mail_info_to": "info@example.com", + "mail_info_subject": "C407 温度監視 定期報告", + "mail_info_template": "mail_info.tera", + "mail_alert_to": "alert@example.com", + "mail_alert_subject": "C407 温度監視 警告", + "mail_alert_template": "mail_alert.tera", + "mail_smtp_server": "localhost", + "mail_smtp_port": 25, + "mail_smtp_security": "smtp", + "mail_smtp_auth": false + }"#; + + let config: Config = serde_json::from_str(json).unwrap(); + + assert!(config.room_name().is_err()); + } + + #[test] + fn room_name_is_required() { + let json = r#"{ + "url": "https://example.com/temperature/", + "digitemp": "/bin/digitemp_DS9097U", + "digitemp_config": "etc/digitemp.conf", + "database_dir": "db", + "images_dir": "html/images", + "templates_dir": "templates", + "mail_alert_upper": 30, + "mail_alert_lower": 17, + "mail_from": "from@example.com", + "mail_from_name": "S108 温度監視プログラム", + "mail_info_to": "info@example.com", + "mail_info_subject": "S108 温度監視 定期報告", + "mail_info_template": "mail_info.tera", + "mail_alert_to": "alert@example.com", + "mail_alert_subject": "S108 温度監視 警告", + "mail_alert_template": "mail_alert.tera", + "mail_smtp_server": "localhost", + "mail_smtp_port": 25, + "mail_smtp_security": "smtp", + "mail_smtp_auth": false + }"#; + + assert!(serde_json::from_str::(json).is_err()); + } +} + +impl Config { + pub fn room_name(&self) -> Result<&str, Box> { + let room_name = self.room_name.trim(); + if room_name.is_empty() { + return Err("room_name must not be empty".into()); + } + Ok(room_name) + } + + pub fn from_file>(path: P) -> Result> { + let data = fs::read_to_string(path)?; + let config: Config = serde_json::from_str(&data)?; + config.room_name()?; + Ok(config) + } +} diff --git a/crates/core/src/digitemp.rs b/crates/core/src/digitemp.rs new file mode 100644 index 0000000..04c409d --- /dev/null +++ b/crates/core/src/digitemp.rs @@ -0,0 +1,74 @@ +use std::fs; +use std::io::{self, BufRead}; +use std::path::Path; +use std::process::Command; + +#[derive(Debug)] +pub struct DigiTemp { + pub command_path: String, + pub config_path: String, + pub sensors: Vec, +} + +impl DigiTemp { + pub fn new(command_path: String, config_path: String) -> io::Result { + let sensors = Self::parse_config(&config_path)?; + Ok(DigiTemp { + command_path, + config_path, + sensors, + }) + } + + pub fn get_num_sensors(&self) -> usize { + self.sensors.len() + } + + pub fn get_sensor_id(&self, num: usize) -> Option<&str> { + self.sensors.get(num).map(|s| s.as_str()) + } + + pub fn read_sensor(&self, num: usize) -> io::Result { + let output = Command::new(&self.command_path) + .arg("-c") + .arg(&self.config_path) + .arg("-q") + .arg("-t") + .arg(num.to_string()) + .arg("-o%.2C") + .output()?; + if !output.status.success() { + return Err(io::Error::new( + io::ErrorKind::Other, + "digitemp command failed", + )); + } + let stdout = String::from_utf8_lossy(&output.stdout); + let value = stdout + .trim() + .parse::() + .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + Ok(value) + } + + fn parse_config>(path: P) -> io::Result> { + let file = fs::File::open(path)?; + let reader = io::BufReader::new(file); + let mut sensors = Vec::new(); + for line in reader.lines() { + let line = line?; + if line.starts_with("ROM ") { + let parts: Vec<&str> = line.split_whitespace().collect(); + if parts.len() > 2 { + let rom_id = parts[2..] + .iter() + .map(|s| s.trim_start_matches("0x")) + .rev() + .collect::(); + sensors.push(rom_id); + } + } + } + Ok(sensors) + } +} diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs new file mode 100644 index 0000000..220f6f2 --- /dev/null +++ b/crates/core/src/lib.rs @@ -0,0 +1,5 @@ +pub mod config; +pub mod digitemp; +pub mod mail; +pub mod rrd; +pub mod template; diff --git a/crates/core/src/mail.rs b/crates/core/src/mail.rs new file mode 100644 index 0000000..bc6c4f4 --- /dev/null +++ b/crates/core/src/mail.rs @@ -0,0 +1,89 @@ +use lettre::message::{Mailbox, Message, header}; +use lettre::{SmtpTransport, Transport, transport::smtp::authentication::Credentials}; +use std::error::Error; +use std::io::{Error as IoError, ErrorKind}; + +use crate::config::MailSmtpSecurity; + +pub struct MailSender { + pub smtp_server: String, + pub smtp_port: u16, + pub smtp_security: MailSmtpSecurity, + pub smtp_auth: bool, + pub smtp_username: String, + pub smtp_password: String, +} + +impl MailSender { + pub fn new( + smtp_server: String, + smtp_port: u16, + smtp_security: MailSmtpSecurity, + smtp_auth: bool, + smtp_username: String, + smtp_password: String, + ) -> Self { + MailSender { + smtp_server, + smtp_port, + smtp_security, + smtp_auth, + smtp_username, + smtp_password, + } + } + + fn build_mailer(&self) -> Result> { + let builder = match self.smtp_security { + MailSmtpSecurity::Smtp => { + SmtpTransport::builder_dangerous(&self.smtp_server).port(self.smtp_port) + } + MailSmtpSecurity::Starttls => { + SmtpTransport::starttls_relay(&self.smtp_server)?.port(self.smtp_port) + } + MailSmtpSecurity::Smtps => { + SmtpTransport::relay(&self.smtp_server)?.port(self.smtp_port) + } + }; + + let builder = if self.smtp_auth { + if self.smtp_username.is_empty() || self.smtp_password.is_empty() { + return Err(Box::new(IoError::new( + ErrorKind::InvalidInput, + "mail_smtp_username and mail_smtp_password are required when mail_smtp_auth is true", + ))); + } + + builder.credentials(Credentials::new( + self.smtp_username.clone(), + self.smtp_password.clone(), + )) + } else { + builder + }; + + Ok(builder.build()) + } + + pub fn send_mail( + &self, + from_name: &str, + from_email: &str, + to_name: &str, + to_email: &str, + subject: &str, + body: &str, + ) -> Result<(), Box> { + let from = Mailbox::new(Some(from_name.to_string()), from_email.parse()?); + let to = Mailbox::new(Some(to_name.to_string()), to_email.parse()?); + let email = Message::builder() + .from(from) + .to(to) + .subject(subject) + .header(header::ContentType::TEXT_PLAIN) + .body(body.to_string())?; + let mailer = self.build_mailer()?; + mailer.send(&email)?; + Ok(()) + } +} diff --git a/crates/core/src/rrd.rs b/crates/core/src/rrd.rs new file mode 100644 index 0000000..3f84da4 --- /dev/null +++ b/crates/core/src/rrd.rs @@ -0,0 +1,279 @@ +use std::io; +use std::path::{Path, PathBuf}; +use std::process::Command; + +use chrono::{Local, TimeZone}; +use serde::Serialize; + +#[derive(Debug, Clone, Serialize, PartialEq)] +pub struct LastData { + pub id: String, + pub min: f64, + pub max: f64, + pub average: f64, + pub latest: f64, + pub timestamp: u64, + pub date: String, +} + +#[derive(Debug)] +pub struct RrdTemperature { + pub database_dir: PathBuf, + pub sensor_ids: Vec, +} + +impl RrdTemperature { + pub fn new>(database_dir: P) -> Self { + RrdTemperature { + database_dir: database_dir.as_ref().to_path_buf(), + sensor_ids: Vec::new(), + } + } + + fn get_file_path(&self, id: &str) -> PathBuf { + self.database_dir.join(format!("{}.rrd", id)) + } + + pub fn add_sensor(&mut self, id: &str) -> io::Result<()> { + if !self.sensor_ids.contains(&id.to_string()) { + self.sensor_ids.push(id.to_string()); + } + let fpath = self.get_file_path(id); + if !fpath.exists() { + self.create(id)?; + } + Ok(()) + } + + fn create(&self, id: &str) -> io::Result<()> { + let fpath = self.get_file_path(id); + let status = Command::new("rrdtool") + .arg("create") + .arg(fpath.to_str().unwrap()) + .arg("--step") + .arg("60") + .arg(format!("DS:{}:GAUGE:600:0:100", id)) // Mark missing data as NaN after 600 seconds and clamp values to 0-100. + .arg("RRA:LAST:0.5:1:10080") // Store 1-minute samples for 7 days. + .arg("RRA:LAST:0.5:30:1752000") // Store 30-minute samples for 10 years. + .output()?; + if !status.status.success() { + return Err(io::Error::new( + io::ErrorKind::Other, + "rrdtool create failed", + )); + } + Ok(()) + } + + pub fn update(&self, id: &str, time: u64, value: f64) -> io::Result<()> { + let fpath = self.get_file_path(id); + if !fpath.exists() { + self.create(id)?; + } + let status = Command::new("rrdtool") + .arg("update") + .arg(fpath.to_str().unwrap()) + .arg(format!("{}:{}", time, value)) + .output()?; + if !status.status.success() { + return Err(io::Error::new( + io::ErrorKind::Other, + "rrdtool update failed", + )); + } + Ok(()) + } + + /// Outputs a graph image for all sensors, matching the PHP implementation + pub fn output_graph(&self, room_name: &str, typ: &str, num: i32, fpath: &str) -> io::Result<()> { + // Validate period type + let valid_types = ["hour", "day", "week", "month", "year"]; + if !valid_types.contains(&typ) { + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "Invalid graph type", + )); + } + let start = format!("-{}{}", num, typ); + let colors = [ + "#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#00FFFF", "#FF00FF", "#FF9999", "#99FF99", + "#9999FF", "#FFFF99", "#99FFFF", "#FF99FF", + ]; + // Find max sensor id length for formatting + let id_len = self.sensor_ids.iter().map(|id| id.len()).max().unwrap_or(0); + let mut args = vec![ + String::from("graph"), + fpath.to_string(), + String::from("--imgformat"), + String::from("PNG"), + String::from("--lower-limit"), + String::from("10"), + String::from("--upper-limit"), + String::from("40"), + String::from("--start"), + start, + String::from("--end"), + String::from("now"), + String::from("--width"), + String::from("400"), + String::from("--height"), + String::from("200"), + String::from("--units-exponent"), + String::from("0"), + String::from("--vertical-label"), + String::from("Temperature [°C]"), + String::from("--title"), + format!("{} Temperature - by {}{}(s)\n", room_name, num, typ), + ]; + // DEFs for each sensor + for (key, id) in self.sensor_ids.iter().enumerate() { + let def = format!( + "DEF:B{}={}:{}:LAST", + key, + self.get_file_path(id).to_str().unwrap(), + id + ); + args.push(def); + } + // Header for stats + args.push(format!( + "COMMENT: {} Cur\\: Min\\: Avg\\: Max\\:\\l", + " ".repeat(id_len) + )); + // LINEs and GPRINTs for each sensor + for (key, id) in self.sensor_ids.iter().enumerate() { + let color = colors[key % colors.len()]; + let line = format!( + "LINE2:B{}{}:{}{}", + key, + color, + id, + " ".repeat(id_len - id.len()) + ); + args.push(line); + args.push(format!("GPRINT:B{}:LAST: %-6.2lf", key)); + args.push(format!("GPRINT:B{}:MIN: %-6.2lf", key)); + args.push(format!("GPRINT:B{}:AVERAGE: %-6.2lf", key)); + args.push(format!("GPRINT:B{}:MAX: %-6.2lf\\l", key)); + } + // Last update timestamp + let now = Local::now(); + let last_update = now.format("%Y-%m-%d %H:%M:%S %Z").to_string(); + args.push(format!( + "COMMENT:Last update\\: {}\\r", + last_update.replace(':', "\\:") + )); + // Run rrdtool command + let status = Command::new("rrdtool").args(&args).output()?; + if !status.status.success() { + return Err(io::Error::new(io::ErrorKind::Other, "rrdtool graph failed")); + } + Ok(()) + } + + pub fn read_last_data(&self, id: &str) -> io::Result> { + let fpath = self.get_file_path(id); + let output = Command::new("rrdtool") + .arg("fetch") + .arg(fpath.to_str().unwrap()) + .arg("LAST") + .output()?; + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + return Err(io::Error::other(format!( + "rrdtool fetch failed: {}", + stderr.trim() + ))); + } + + Ok(parse_fetch_output(&String::from_utf8_lossy(&output.stdout), id)) + } +} + +fn parse_fetch_output(output: &str, id: &str) -> Option { + let mut values = Vec::new(); + let mut latest_timestamp = 0; + + for line in output.lines() { + let line = line.trim(); + if line.is_empty() { + continue; + } + + let Some((timestamp, value)) = line.split_once(':') else { + continue; + }; + + let timestamp = match timestamp.trim().parse::() { + Ok(timestamp) => timestamp, + Err(_) => continue, + }; + + let value = value.trim(); + if value.eq_ignore_ascii_case("nan") || value.eq_ignore_ascii_case("-nan") { + continue; + } + + let value = match value.parse::() { + Ok(value) if value != 0.0 => value, + Ok(_) | Err(_) => continue, + }; + + values.push(value); + latest_timestamp = timestamp; + } + + if values.is_empty() { + return None; + } + + let latest = *values.last()?; + let min = values.iter().copied().fold(f64::INFINITY, f64::min); + let max = values.iter().copied().fold(f64::NEG_INFINITY, f64::max); + let average = values.iter().sum::() / values.len() as f64; + + Some(LastData { + id: id.to_string(), + min, + max, + average, + latest, + timestamp: latest_timestamp, + date: format_timestamp(latest_timestamp), + }) +} + +fn format_timestamp(timestamp: u64) -> String { + Local + .timestamp_opt(timestamp as i64, 0) + .single() + .map(|datetime| datetime.format("%Y-%m-%d %H:%M:%S %Z").to_string()) + .unwrap_or_else(|| timestamp.to_string()) +} + +#[cfg(test)] +mod tests { + use super::{format_timestamp, parse_fetch_output}; + + #[test] + fn parse_fetch_output_returns_last_data() { + let output = " 99000800B7732910\n\n1711260000: -nan\n1711260060: 0.0000000000e+00\n1711260120: 2.1500000000e+01\n1711260180: 2.3000000000e+01\n"; + + let data = parse_fetch_output(output, "99000800B7732910").expect("expected data"); + + assert_eq!(data.id, "99000800B7732910"); + assert_eq!(data.min, 21.5); + assert_eq!(data.max, 23.0); + assert_eq!(data.average, 22.25); + assert_eq!(data.latest, 23.0); + assert_eq!(data.timestamp, 1711260180); + assert_eq!(data.date, format_timestamp(1711260180)); + } + + #[test] + fn parse_fetch_output_returns_none_for_empty_series() { + let output = " 99000800B7732910\n\n1711260000: -nan\n1711260060: 0.0000000000e+00\n"; + + assert!(parse_fetch_output(output, "99000800B7732910").is_none()); + } +} \ No newline at end of file diff --git a/crates/core/src/template.rs b/crates/core/src/template.rs new file mode 100644 index 0000000..33d0941 --- /dev/null +++ b/crates/core/src/template.rs @@ -0,0 +1,42 @@ +use std::error::Error; +use std::path::Path; +use tera::{Context, Tera}; + +pub struct TemplateContext { + inner: Context, +} + +impl TemplateContext { + pub fn new() -> Self { + TemplateContext { + inner: Context::new(), + } + } + pub fn insert(&mut self, key: &str, value: &V) { + self.inner.insert(key, value); + } + pub(crate) fn as_inner(&self) -> &Context { + &self.inner + } +} + +pub struct TemplateEngine { + tera: Tera, +} + +impl TemplateEngine { + pub fn new>(template_dir: P) -> Result> { + let pattern = format!("{}/**/*", template_dir.as_ref().display()); + let tera = Tera::new(&pattern)?; + Ok(TemplateEngine { tera }) + } + + pub fn render( + &self, + template: &str, + context: &TemplateContext, + ) -> Result> { + let rendered = self.tera.render(template, context.as_inner())?; + Ok(rendered) + } +} diff --git a/db/.gitkeep b/db/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/etc/crontab.sample b/etc/crontab.sample new file mode 100644 index 0000000..47e32ad --- /dev/null +++ b/etc/crontab.sample @@ -0,0 +1,9 @@ +# +# Server Room Temperature Monitoring System +# +# update minutely temperature sensor data +* * * * * admin /opt/digitemp_rrdgraph/bin/digitemp_rrdgraph update +# send daily temperature informations +1 12 * * * admin php /opt/digitemp_rrdgraph/bin/digitemp_rrdgraph send-info +# check alert thresholds on every 15 minutes +0,15,30,45 * * * * admin /opt/digitemp_rrdgraph/bin/digitemp_rrdgraph check-alert diff --git a/etc/digitemp-rrdgraph.sample.json b/etc/digitemp-rrdgraph.sample.json new file mode 100644 index 0000000..484718c --- /dev/null +++ b/etc/digitemp-rrdgraph.sample.json @@ -0,0 +1,25 @@ +{ + "url": "https://www.ni.riken.jp/temperature/", + "digitemp": "/bin/digitemp_DS9097U", + "digitemp_config": "/opt/digitemp-rrdgraph/etc/digitemp.conf", + "database_dir": "/opt/digitemp-rrdgraph/db", + "images_dir": "/opt/digitemp-rrdgraph/html/images", + "templates_dir": "/opt/digitemp-rrdgraph/templates", + "room_name": "C407", + "mail_alert_upper": 30, + "mail_alert_lower": 17, + "mail_from": "cbs-is@ml.riken.jp", + "mail_from_name": "C407 温度監視プログラム", + "mail_info_to": "niu-log@ml.riken.jp", + "mail_info_subject": "C407 温度監視 定期報告", + "mail_info_template": "mail_info.tera", + "mail_alert_to": "cbs-is@ml.riken.jp", + "mail_alert_subject": "C407 温度監視 警告", + "mail_alert_template": "mail_alert.tera", + "mail_smtp_server": "smtp.example.com", + "mail_smtp_port": 587, + "mail_smtp_security": "starttls", + "mail_smtp_auth": true, + "mail_smtp_username": "user@example.com", + "mail_smtp_password": "password" +} diff --git a/etc/digitemp.sample.conf b/etc/digitemp.sample.conf new file mode 100644 index 0000000..45f5c9b --- /dev/null +++ b/etc/digitemp.sample.conf @@ -0,0 +1,9 @@ +TTY /dev/ttyS1 +READ_TIME 1000 +LOG_TYPE 1 +LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F" +CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C" +HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%" +SENSORS 2 +ROM 0 0x10 0xF5 0x89 0xB7 0x00 0x08 0x00 0x3B +ROM 1 0x10 0xA3 0x85 0xB7 0x00 0x08 0x00 0x86 diff --git a/html/css/default.css b/html/css/default.css new file mode 100644 index 0000000..9effc01 --- /dev/null +++ b/html/css/default.css @@ -0,0 +1,27 @@ +body { + margin: 2em 1em 0 3em; + color: black; + background: white; + background-position: top left; + background-attachment: fixed; + background-repeat: no-repeat; + background-image: url(logo.png); + text-align: center; +} + +h1 { text-align: center; } +h2, h3, h4, h5, h6 { text-align: left; } +h1 { color: black; font: 120% sans-serif; font-weight: bold; } +h2 { color: #005A9C; font: 110%; font-weight: medium; } +h3 { color: #001A4C; font: 105% sans-serif; font-weight: medium; } +h4 { color: #007A9C; font: 90% sans-serif; font-weight: medium; } +h5 { color: #005A9C; font: italic 80% sans-serif; } +h6 { font: small-caps 70% sans-serif; } + +img { width: auto; height: auto; max-width: 100%; max-height: 100%; } + +main { display: flex; flex-wrap: wrap; } +main div.graph { margin: 5px auto; } +main div.range-select span { color: blue; text-decoration: underline; cursor: pointer; } + + diff --git a/html/css/logo.png b/html/css/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..49fdb23ba7f3d0b409477de2073920e80d582661 GIT binary patch literal 3144 zcmWNU_aoE|9Du(kdsVVhB=we@kfO{8*<^G?xP*{Z$V$!;ZUi65PmL0S3hJIgS{X8&u==E)j?b)=)1!GV3?W#JqNIO3?mb; zLIXlN43C1%BXA4?`X+>@fRQsStpI%sHn*U;8)DPpRR#=>LiYeXjR9OV1iXT8-y!%l zbPs{7DLf7XOJA5>fb>%Ed=ABRP}>UMe?Va^=wKl(1MqQR7X;TVz}g22s)5)6c@>~y z1D-hey$O{>=>G!MAK`5&zJR=~h7(TRvGagoH(9#2ARB#T1h(xGpgpb{jQ36-Y z;R^-A<6(Lhp1lSa9K5T7f5?zj07?0$kE;Qazt{{`|mEU!UA4m7kwL<%gg z!slVA?|>gmP}cz;x?p<;@@pZb0Q6$hdk}=JSyxlt+#j`K(ur!7VT}qZ>^pclY9ot! z8fqrXl^=CUD%^a+azP_pQu=eT$Argt`9p;=devIU=;x*}j%&ujU*>ny(n=`;Ufa8) z*Qw5&X!ZNfZf;|e-zFxiWK`Spn*Xe`H_vruXoN+`H|WP65pA=<2L+xcCj=^W=C7^I zZe35S-qK|l{Q5BKQ5K!9oWAlcFlntLM2J%V2OGNkkwbO~clz4dH_ghD=?olEe>+IW z5SZ=lwJI9?pVTli_47PW3JYDmiqg@$NkAgVSuBF%Uuul6>qjE|EY-&mSxWC|oG@~E zUX&$_m0yt4lBZ!zwwkrG%Dc&YRV1$j;J2+w^s>NNxLx)T4WBZN*`9yk+_(Xj=l+*#!# z_g5-8S01!BjOyPJLK-KCOb;n8JH?P#%|l=b7f zi4>!BMx5mE0*1x7(k%DQ;2Dhutl12&WE9wvvoEYy_?HqA zYRNeGF%KLIY(5#TxZSbfx3|RU6fMDo?8^3VX*}0>zJVa@FD{ z1``ksYQo9OYh>zeB*lJYXeATrDiA><`OkvQ-Dp-SkxCkvH58@NKTgFc4qazLxu%D9 zibE&~jclmYF>W>#MF9(E`(q8A!nyyX{?6S?Wgvbb`9>s_hT+v4%9?zvM} zp?VWff7Ei8TbG-khyD5|r}NYO&cQvABrRSopwy&;dx=AJb^$G5E5{N2q@J^ZL2Ep~@INH#-sdy|Ki zJ`qCWq)~GZo>C#B6Lw>Zsjjt%-qzQ%r2RZszZPk-K4_(z~0)O?}nVAVE zCMwqYm&PphU)0+-RkTs=|2K0_4%O9QceiP3AH(jnn(Ek@s}RTd%bYk!4%ba%N^ZWG z9*f%fu3J`FxC2HXZ($WKMh8P#0s2`JB@=>qu+c~E(HFZ(#cl&d>6nk}~Tco!@ z+qub-%kw#Jv8iwA?23<_4$A zS7Ob8eN`x<_uFMwC56i7kjcC!IRT;{miTYhQ3(p-M?x<^g z8MH0G^~x=+FZMwplZ?q^y6boO^Elu3UfEliz`054pq|;8eWS7-0b8l8lx@=7gmVK`2cEw}wi`<-Y&JUD$Y>{MK4C&7EsureZt51$0pQ45dZLSqI zS$a1_%91mTMcip5H32E2*{;J*D)VLadsnCVvfHBAae3T7S%c+Mr_SyxB$8}G+>)7p z`H8U`ENb2m|D$x2sY}u1_dof}33yM;qS2?;lLtnc_)4SSrg4WIq{2cMHQQgO>7bp+ z67h^tT+`>pMaZfz{M8RvVHLJ~qkGxG{?W3g|?SUCSb1VmTMNVEI~7XKfU Ce~xwl literal 0 HcmV?d00001 diff --git a/html/images/.gitkeep b/html/images/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/commands.rs b/src/commands.rs new file mode 100644 index 0000000..0017672 --- /dev/null +++ b/src/commands.rs @@ -0,0 +1,3 @@ +pub mod check_alert; +pub mod send_info; +pub mod update; \ No newline at end of file diff --git a/src/commands/check_alert.rs b/src/commands/check_alert.rs new file mode 100644 index 0000000..daac589 --- /dev/null +++ b/src/commands/check_alert.rs @@ -0,0 +1,52 @@ +use digitemp_rrdgraph_core::config::Config; +use digitemp_rrdgraph_core::digitemp::DigiTemp; +use digitemp_rrdgraph_core::mail::MailSender; +use digitemp_rrdgraph_core::rrd::RrdTemperature; +use digitemp_rrdgraph_core::template::{TemplateContext, TemplateEngine}; +use serde_json::json; +use std::error::Error; + +pub fn run(config: &Config) -> Result<(), Box> { + let digitemp = DigiTemp::new(config.digitemp.clone(), config.digitemp_config.clone())?; + let mut rrdtemp = RrdTemperature::new(&config.database_dir); + let num = digitemp.get_num_sensors(); + let mut sensors = Vec::new(); + for i in 0..num { + let id = digitemp.get_sensor_id(i).unwrap(); + rrdtemp.add_sensor(id)?; + if let Some(sensor) = rrdtemp.read_last_data(id)? { + sensors.push(sensor); + } + } + let upper = config.mail_alert_upper; + let lower = config.mail_alert_lower; + let do_send = sensors + .iter() + .any(|sensor| sensor.latest < lower || sensor.latest > upper); + if do_send { + let from = &config.mail_from; + let from_name = &config.mail_from_name; + let to = &config.mail_alert_to; + let subject = &config.mail_alert_subject; + let room_name = config.room_name()?; + let engine = TemplateEngine::new(&config.templates_dir)?; + let mut ctx = TemplateContext::new(); + ctx.insert("range", &json!({"upper": upper, "lower": lower})); + ctx.insert("sensors", &sensors); + ctx.insert("from", &json!({"name": from_name, "email": from})); + ctx.insert("room_name", &room_name); + ctx.insert("subject", subject); + ctx.insert("url", &config.url); + let body = engine.render(&config.mail_alert_template, &ctx)?; + let mailer = MailSender::new( + config.mail_smtp_server.clone(), + config.mail_smtp_port, + config.mail_smtp_security.clone(), + config.mail_smtp_auth, + config.mail_smtp_username.clone(), + config.mail_smtp_password.clone(), + ); + mailer.send_mail(from_name, from, to, to, subject, &body)?; + } + Ok(()) +} diff --git a/src/commands/send_info.rs b/src/commands/send_info.rs new file mode 100644 index 0000000..05685df --- /dev/null +++ b/src/commands/send_info.rs @@ -0,0 +1,44 @@ +use digitemp_rrdgraph_core::config::Config; +use digitemp_rrdgraph_core::digitemp::DigiTemp; +use digitemp_rrdgraph_core::mail::MailSender; +use digitemp_rrdgraph_core::rrd::RrdTemperature; +use digitemp_rrdgraph_core::template::{TemplateContext, TemplateEngine}; +use serde_json::json; +use std::error::Error; + +pub fn run(config: &Config) -> Result<(), Box> { + let digitemp = DigiTemp::new(config.digitemp.clone(), config.digitemp_config.clone())?; + let mut rrdtemp = RrdTemperature::new(&config.database_dir); + let num = digitemp.get_num_sensors(); + let mut sensors = Vec::new(); + for i in 0..num { + let id = digitemp.get_sensor_id(i).unwrap(); + rrdtemp.add_sensor(id)?; + if let Some(sensor) = rrdtemp.read_last_data(id)? { + sensors.push(sensor); + } + } + let from = &config.mail_from; + let from_name = &config.mail_from_name; + let to = &config.mail_info_to; + let subject = &config.mail_info_subject; + let room_name = config.room_name()?; + let engine = TemplateEngine::new(&config.templates_dir)?; + let mut ctx = TemplateContext::new(); + ctx.insert("from", &json!({"name": from_name, "email": from})); + ctx.insert("room_name", &room_name); + ctx.insert("sensors", &sensors); + ctx.insert("subject", subject); + ctx.insert("url", &config.url); + let body = engine.render(&config.mail_info_template, &ctx)?; + let mailer = MailSender::new( + config.mail_smtp_server.clone(), + config.mail_smtp_port, + config.mail_smtp_security.clone(), + config.mail_smtp_auth, + config.mail_smtp_username.clone(), + config.mail_smtp_password.clone(), + ); + mailer.send_mail(from_name, from, to, to, subject, &body)?; + Ok(()) +} diff --git a/src/commands/update.rs b/src/commands/update.rs new file mode 100644 index 0000000..5f4671a --- /dev/null +++ b/src/commands/update.rs @@ -0,0 +1,52 @@ +use digitemp_rrdgraph_core::config::Config; +use digitemp_rrdgraph_core::digitemp::DigiTemp; +use digitemp_rrdgraph_core::rrd::RrdTemperature; +use digitemp_rrdgraph_core::template::{TemplateContext, TemplateEngine}; +use std::error::Error; +use std::fs; +use std::path::Path; +use std::time::{SystemTime, UNIX_EPOCH}; + +pub fn run(config: &Config) -> Result<(), Box> { + let room_name = config.room_name()?; + let digitemp = DigiTemp::new(config.digitemp.clone(), config.digitemp_config.clone())?; + let mut rrdtemp = RrdTemperature::new(&config.database_dir); + let num = digitemp.get_num_sensors(); + for i in 0..num { + let id = digitemp.get_sensor_id(i).unwrap(); + let value = digitemp.read_sensor(i)?; + rrdtemp.add_sensor(id)?; + let now = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs(); + rrdtemp.update(id, now, value)?; + } + let types = vec![ + ("hour", vec![1, 3, 6, 12]), + ("day", vec![1, 3]), + ("week", vec![1, 2]), + ("month", vec![1, 3, 6]), + ("year", vec![1, 3, 5, 10]), + ]; + for (typ, nums) in types { + for num in nums { + let num_str = if num == 1 { + "".to_string() + } else { + num.to_string() + }; + let fpath = format!("{}/graph-{}{}.png", config.images_dir, num_str, typ); + rrdtemp.output_graph(room_name, typ, num, &fpath)?; + } + } + + let engine = TemplateEngine::new(&config.templates_dir)?; + let mut ctx = TemplateContext::new(); + ctx.insert("room_name", &room_name); + let html = engine.render("index.tera", &ctx)?; + let index_path = Path::new(&config.images_dir) + .parent() + .unwrap_or_else(|| Path::new("html")) + .join("index.html"); + fs::write(index_path, html)?; + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d6e6143 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,174 @@ +mod commands; + +use clap::{Parser, Subcommand}; +use digitemp_rrdgraph_core::config::Config; +use std::env; +use std::error::Error; +use std::io; +use std::path::{Path, PathBuf}; + +#[derive(Parser)] +#[command(author, version, about)] +struct Cli { + #[arg( + short, + long, + global = true, + help = "Print the selected configuration file path to standard error" + )] + verbose: bool, + + #[arg( + short, + long, + global = true, + value_name = "PATH", + help = "Load configuration from PATH instead of using the default search order" + )] + config: Option, + + #[command(subcommand)] + command: Commands, +} + +#[derive(Subcommand)] +enum Commands { + Update, + CheckAlert, + SendInfo, +} + +const CONFIG_FILE_NAME: &str = "digitemp-rrdgraph.json"; + +fn config_candidates( + home_dir: Option<&Path>, + executable_root_dir: Option<&Path>, + current_dir: &Path, +) -> Vec { + let mut candidates = Vec::with_capacity(4); + + if let Some(home_dir) = home_dir { + candidates.push(home_dir.join(".config").join(CONFIG_FILE_NAME)); + } + + candidates.push(PathBuf::from("/etc").join(CONFIG_FILE_NAME)); + + if let Some(executable_root_dir) = executable_root_dir { + candidates.push(executable_root_dir.join("etc").join(CONFIG_FILE_NAME)); + } + + candidates.push(current_dir.join("etc").join(CONFIG_FILE_NAME)); + + candidates +} + +fn resolve_config_path() -> Result> { + let home_dir = env::var_os("HOME").map(PathBuf::from); + let executable_root_dir = env::current_exe()? + .parent() + .and_then(Path::parent) + .map(Path::to_path_buf); + let current_dir = env::current_dir()?; + let candidates = config_candidates( + home_dir.as_deref(), + executable_root_dir.as_deref(), + ¤t_dir, + ); + + candidates + .iter() + .find(|path| path.is_file()) + .cloned() + .ok_or_else(|| { + let searched = candidates + .iter() + .map(|path| path.display().to_string()) + .collect::>() + .join(", "); + io::Error::new( + io::ErrorKind::NotFound, + format!("configuration file not found; searched: {searched}"), + ) + .into() + }) +} + +fn resolve_config_path_from_cli(config_path: Option) -> Result> { + match config_path { + Some(path) => Ok(path), + None => resolve_config_path(), + } +} + +fn main() -> Result<(), Box> { + let cli = Cli::parse(); + let config_path = resolve_config_path_from_cli(cli.config.clone())?; + if cli.verbose { + eprintln!("Using configuration file: {}", config_path.display()); + } + let config = Config::from_file(&config_path)?; + match cli.command { + Commands::Update => { + commands::update::run(&config)?; + } + Commands::CheckAlert => { + commands::check_alert::run(&config)?; + } + Commands::SendInfo => { + commands::send_info::run(&config)?; + } + } + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::{CONFIG_FILE_NAME, config_candidates, resolve_config_path_from_cli}; + use std::path::{Path, PathBuf}; + + #[test] + fn config_candidates_follow_expected_precedence() { + let candidates = config_candidates( + Some(Path::new("/home/testuser")), + Some(Path::new("/opt/digitemp-rrdgraph")), + Path::new("/work/app"), + ); + + assert_eq!( + candidates, + vec![ + Path::new("/home/testuser") + .join(".config") + .join(CONFIG_FILE_NAME), + Path::new("/etc").join(CONFIG_FILE_NAME), + Path::new("/opt/digitemp-rrdgraph") + .join("etc") + .join(CONFIG_FILE_NAME), + Path::new("/work/app").join("etc").join(CONFIG_FILE_NAME), + ] + ); + } + + #[test] + fn config_candidates_skip_optional_entries_when_paths_are_missing() { + let candidates = config_candidates(None, None, Path::new("/work/app")); + + assert_eq!( + candidates, + vec![ + Path::new("/etc").join(CONFIG_FILE_NAME), + Path::new("/work/app").join("etc").join(CONFIG_FILE_NAME), + ] + ); + } + + #[test] + fn explicit_config_path_takes_precedence_over_search_order() { + let config_path = PathBuf::from("/tmp/custom-config.json"); + + assert_eq!( + resolve_config_path_from_cli(Some(config_path.clone())).unwrap(), + config_path + ); + } +} diff --git a/templates/index.tera b/templates/index.tera new file mode 100644 index 0000000..3292dc2 --- /dev/null +++ b/templates/index.tera @@ -0,0 +1,72 @@ + + + + + Temperature Monitor - {{ room_name }} + + + + + + + + +

Temperature Monitor - {{ room_name }}

+ +
+
+
+ Hour: + 1 ... + 3 ... + 6 ... + 12 +
+
Hourly Graph
+
+
+
+ Day: + 1 ... + 3 +
+
Daily Graph
+
+
+
+ Week: + 1 ... + 2 +
+
Weekly Graph
+
+
+
+ Month: + 1 ... + 3 ... + 6 +
+
Monthly Graph
+
+
+
+ Year: + 1 ... + 3 ... + 5 ... + 10 +
+
Yearly Graph
+
+
+ + + \ No newline at end of file diff --git a/templates/mail_alert.tera b/templates/mail_alert.tera new file mode 100644 index 0000000..1350b3f --- /dev/null +++ b/templates/mail_alert.tera @@ -0,0 +1,14 @@ +{{ subject }} + +警告温度に到達しました。 +許容範囲({{ range.lower | round(precision=2) }} 〜 {{ range.upper | round(precision=2) }} ℃)外の温度です。 + +{{ room_name }} の環境を確認してください。 + +{% for sensor in sensors -%} +{% include "mail_sensor.inc.tera" %} +{% endfor -%} + +-- +{{ from.name }} <{{ from.email }}> +{{ url }} \ No newline at end of file diff --git a/templates/mail_info.tera b/templates/mail_info.tera new file mode 100644 index 0000000..6fd919d --- /dev/null +++ b/templates/mail_info.tera @@ -0,0 +1,9 @@ +{{ subject }} + +{% for sensor in sensors -%} +{% include "mail_sensor.inc.tera" %} +{% endfor -%} + +-- +{{ from.name }} <{{ from.email }}> +{{ url }} \ No newline at end of file diff --git a/templates/mail_sensor.inc.tera b/templates/mail_sensor.inc.tera new file mode 100644 index 0000000..87d669d --- /dev/null +++ b/templates/mail_sensor.inc.tera @@ -0,0 +1,6 @@ +--- センサー #{{ sensor.id }} --- +最新測定日時:{{ sensor.date }} +最新温度:  {{ sensor.latest | round(precision=2) }} ℃ +平均/日:  {{ sensor.average | round(precision=2) }} ℃ +最高値/日: {{ sensor.max | round(precision=2) }} ℃ +最低値/日: {{ sensor.min | round(precision=2) }} ℃