{"id":16380253,"url":"https://github.com/aramperes/nut-rs","last_synced_at":"2025-12-12T14:18:18.103Z","repository":{"id":40316008,"uuid":"313824938","full_name":"aramperes/nut-rs","owner":"aramperes","description":"rups: A Network UPS Tools (NUT) implementation in Rust.","archived":false,"fork":false,"pushed_at":"2024-01-07T04:08:33.000Z","size":121,"stargazers_count":24,"open_issues_count":8,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T03:50:55.762Z","etag":null,"topics":["async","hacktoberfest","network-ups-tools","nut","rust","rust-library","tokio","ups"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/rups","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aramperes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-11-18T04:43:12.000Z","updated_at":"2024-10-08T06:47:17.000Z","dependencies_parsed_at":"2024-01-07T05:30:50.220Z","dependency_job_id":null,"html_url":"https://github.com/aramperes/nut-rs","commit_stats":{"total_commits":54,"total_committers":4,"mean_commits":13.5,"dds":"0.16666666666666663","last_synced_commit":"0b69b3fc477ce9ddeb15bb7f98b0c886f0b764f6"},"previous_names":["aramperes/nut-client-rs"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aramperes%2Fnut-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aramperes%2Fnut-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aramperes%2Fnut-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aramperes%2Fnut-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aramperes","download_url":"https://codeload.github.com/aramperes/nut-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221665750,"owners_count":16860307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","hacktoberfest","network-ups-tools","nut","rust","rust-library","tokio","ups"],"created_at":"2024-10-11T03:50:57.591Z","updated_at":"2025-12-12T14:18:18.068Z","avatar_url":"https://github.com/aramperes.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rups\n\n[![crates.io](https://img.shields.io/crates/v/rups.svg)](https://crates.io/crates/rups)\n[![Documentation](https://docs.rs/rups/badge.svg)](https://docs.rs/rups)\n[![MIT licensed](https://img.shields.io/crates/l/rups.svg)](./LICENSE)\n[![CI](https://github.com/aramperes/nut-rs/workflows/CI/badge.svg)](https://github.com/aramperes/nut-rs/actions?query=workflow%3ACI)\n\nA [Network UPS Tools](https://github.com/networkupstools/nut) (NUT) client library for Rust.\n\n- Connect to `upsd`/`nut-server` using TCP\n- Login with username and password\n- List UPS devices\n- List variables for a UPS device\n- Connect securely with SSL (optional feature)\n- Supports blocking and async (Tokio)\n\n## Getting Started\n\nYou'll need a running instance of the NUT daemon (`upsd`, version \u003e= 2.6.4) and\na [compatible UPS device](https://networkupstools.org/stable-hcl.html)\nto use this library:\n\n1. [Install NUT](https://networkupstools.org/docs/user-manual.chunked/ar01s05.html)\n2. [Configure and launch upsd](https://networkupstools.org/docs/user-manual.chunked/ar01s06.html)\n\nVerify that your UPS is connected using the built-in `upsc` tool:\n\n```bash\nupsc myupsname@localhost ups.status\n```\n\n## Example\n\nThe [rupsc](https://github.com/aramperes/nut-rs/tree/master/rupsc)\nCLI is written using this library, and is a clone of NUT's\nbuilt-in [upsc](https://networkupstools.org/docs/man/upsc.html) tool.\n\nBelow is a sample program using this library (`cargo run --example blocking`).\n\nYou can also run the async version of this code using\n`cargo run --example async --features async-rt` (source: `rups/examples/async.rs`).\n\n```rust\n// rups/examples/blocking.rs\n\nuse std::env;\n\nuse rups::blocking::Connection;\nuse rups::{Auth, ConfigBuilder};\nuse std::convert::TryInto;\n\nfn main() -\u003e nut_client::Result\u003c()\u003e {\n    let host = env::var(\"NUT_HOST\").unwrap_or_else(|_| \"localhost\".into());\n    let port = env::var(\"NUT_PORT\")\n        .ok()\n        .and_then(|s| s.parse::\u003cu16\u003e().ok())\n        .unwrap_or(3493);\n\n    let username = env::var(\"NUT_USER\").ok();\n    let password = env::var(\"NUT_PASSWORD\").ok();\n    let auth = username.map(|username| Auth::new(username, password));\n\n    let config = ConfigBuilder::new()\n        .with_host((host, port).try_into().unwrap_or_default())\n        .with_auth(auth)\n        .with_debug(false) // Turn this on for debugging network chatter\n        .build();\n\n    let mut conn = Connection::new(\u0026config)?;\n\n    // Print a list of all UPS devices\n    println!(\"Connected UPS devices:\");\n    for (name, description) in conn.list_ups()? {\n        println!(\"\\t- Name: {}\", name);\n        println!(\"\\t  Description: {}\", description);\n\n        // List UPS variables (key = val)\n        println!(\"\\t  Variables:\");\n        for var in conn.list_vars(\u0026name)? {\n            println!(\"\\t\\t- {}\", var);\n        }\n    }\n\n    Ok(())\n}\n```\n\n## SSL\n\nYou can turn on SSL support by adding `.with_ssl(true)` in the `ConfigBuilder`. This requires the `ssl` feature, which\nuses `rustls` under the hood.\n\nNote that, by default, `.with_ssl(true)` will enable **strict** verification. This means it will verify the server\ncertificate's DNS entries, check for revocation, and verify the chain using the local root trust. You must also ensure\nthat the connection hostname is a valid DNS name (e.g. `localhost`, not `127.0.0.1`).\n\nIf the server is using a self-signed certificate, and you'd like to ignore the strict validation, you can add\n`.with_insecure_ssl(true)` along with `.with_ssl(true)`.\n\n## Async (Tokio)\n\nThe `rups` library supports async network requests. This requires the `async` feature, which uses Tokio v1 under the\nhood.\n\nFor SSL support, you must use the `async-ssl` feature as well.\n\n## Pronunciation\n\n\u003e r-oops\n\n## License\n\nThe crates in this repository are licensed as such:\n\n- `rups`: MIT License, see `./LICENSE`\n- `rupsc`: GPL-3.0 or later, see `./rupsc/LICENSE`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faramperes%2Fnut-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faramperes%2Fnut-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faramperes%2Fnut-rs/lists"}