mirror of
https://github.com/aramperes/nut-rs.git
synced 2025-09-08 05:08:31 -04:00
Release 0.5.0
Rename to rups
This commit is contained in:
parent
539d11848e
commit
feef67255f
21 changed files with 51 additions and 47 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -171,18 +171,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nut-client"
|
|
||||||
version = "0.4.0"
|
|
||||||
dependencies = [
|
|
||||||
"rustls",
|
|
||||||
"shell-words",
|
|
||||||
"tokio",
|
|
||||||
"tokio-rustls",
|
|
||||||
"webpki",
|
|
||||||
"webpki-roots",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
|
@ -228,13 +216,25 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rups"
|
||||||
|
version = "0.5.0"
|
||||||
|
dependencies = [
|
||||||
|
"rustls",
|
||||||
|
"shell-words",
|
||||||
|
"tokio",
|
||||||
|
"tokio-rustls",
|
||||||
|
"webpki",
|
||||||
|
"webpki-roots",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rupsc"
|
name = "rupsc"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
"nut-client",
|
"rups",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"nut-client",
|
"rups",
|
||||||
"rupsc"
|
"rupsc"
|
||||||
]
|
]
|
||||||
|
|
24
README.md
24
README.md
|
@ -1,8 +1,8 @@
|
||||||
# nut-client
|
# rups
|
||||||
|
|
||||||
[](https://crates.io/crates/nut-client)
|
[](https://crates.io/crates/rups)
|
||||||
[](https://docs.rs/nut-client)
|
[](https://docs.rs/rups)
|
||||||
[](./LICENSE)
|
[](./LICENSE)
|
||||||
[](https://github.com/aramperes/nut-client-rs/actions?query=workflow%3ACI)
|
[](https://github.com/aramperes/nut-client-rs/actions?query=workflow%3ACI)
|
||||||
|
|
||||||
A [Network UPS Tools](https://github.com/networkupstools/nut) (NUT) client library for Rust.
|
A [Network UPS Tools](https://github.com/networkupstools/nut) (NUT) client library for Rust.
|
||||||
|
@ -38,15 +38,15 @@ built-in [upsc](https://networkupstools.org/docs/man/upsc.html) tool.
|
||||||
Below is a sample program using this library (`cargo run --example blocking`).
|
Below is a sample program using this library (`cargo run --example blocking`).
|
||||||
|
|
||||||
You can also run the async version of this code using
|
You can also run the async version of this code using
|
||||||
`cargo run --example async --features async-rt` (source: `nut-client/examples/async.rs`).
|
`cargo run --example async --features async-rt` (source: `rups/examples/async.rs`).
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// nut-client/examples/blocking.rs
|
// rups/examples/blocking.rs
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use nut_client::blocking::Connection;
|
use rups::blocking::Connection;
|
||||||
use nut_client::{Auth, ConfigBuilder};
|
use rups::{Auth, ConfigBuilder};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
fn main() -> nut_client::Result<()> {
|
fn main() -> nut_client::Result<()> {
|
||||||
|
@ -100,7 +100,11 @@ If the server is using a self-signed certificate, and you'd like to ignore the s
|
||||||
|
|
||||||
## Async (Tokio)
|
## Async (Tokio)
|
||||||
|
|
||||||
The `nut-client` library supports async network requests. This requires the `async` feature, which uses Tokio v1 under
|
The `rups` library supports async network requests. This requires the `async` feature, which uses Tokio v1 under the
|
||||||
the hood.
|
hood.
|
||||||
|
|
||||||
For SSL support, you must use the `async-ssl` feature as well.
|
For SSL support, you must use the `async-ssl` feature as well.
|
||||||
|
|
||||||
|
## Pronunciation
|
||||||
|
|
||||||
|
> r-oops
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nut-client"
|
name = "rups"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
authors = ["Aram Peres <aram.peres@wavy.fm>"]
|
authors = ["Aram Peres <aram.peres@wavy.fm>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Network UPS Tools (NUT) client library"
|
description = "Network UPS Tools (NUT) client library"
|
||||||
categories = ["network-programming"]
|
categories = ["network-programming"]
|
||||||
keywords = ["ups", "nut", "tokio", "async"]
|
keywords = ["ups", "nut", "tokio", "async"]
|
||||||
repository = "https://github.com/aramperes/nut-client-rs"
|
repository = "https://github.com/aramperes/nut-client-rs"
|
||||||
documentation = "https://docs.rs/nut-client"
|
documentation = "https://docs.rs/rups"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use nut_client::tokio::Connection;
|
use rups::tokio::Connection;
|
||||||
use nut_client::{Auth, ConfigBuilder};
|
use rups::{Auth, ConfigBuilder};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> nut_client::Result<()> {
|
async fn main() -> rups::Result<()> {
|
||||||
let host = env::var("NUT_HOST").unwrap_or_else(|_| "localhost".into());
|
let host = env::var("NUT_HOST").unwrap_or_else(|_| "localhost".into());
|
||||||
let port = env::var("NUT_PORT")
|
let port = env::var("NUT_PORT")
|
||||||
.ok()
|
.ok()
|
|
@ -1,10 +1,10 @@
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use nut_client::blocking::Connection;
|
use rups::blocking::Connection;
|
||||||
use nut_client::{Auth, ConfigBuilder};
|
use rups::{Auth, ConfigBuilder};
|
||||||
|
|
||||||
fn main() -> nut_client::Result<()> {
|
fn main() -> rups::Result<()> {
|
||||||
let host = env::var("NUT_HOST").unwrap_or_else(|_| "localhost".into());
|
let host = env::var("NUT_HOST").unwrap_or_else(|_| "localhost".into());
|
||||||
let port = env::var("NUT_PORT")
|
let port = env::var("NUT_PORT")
|
||||||
.ok()
|
.ok()
|
|
@ -1,8 +1,8 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
//! # nut-client
|
//! # rups
|
||||||
//!
|
//!
|
||||||
//! The `nut-client` crate provides a network client implementation
|
//! The `rups` crate provides a network client implementation
|
||||||
//! for Network UPS Tools (NUT) servers.
|
//! for Network UPS Tools (NUT) servers.
|
||||||
|
|
||||||
pub use config::*;
|
pub use config::*;
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rupsc"
|
name = "rupsc"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
authors = ["Aram Peres <aram.peres@wavy.fm>"]
|
authors = ["Aram Peres <aram.peres@wavy.fm>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "A demo program to display UPS variables"
|
description = "A demo program to display UPS variables"
|
||||||
|
@ -16,7 +16,7 @@ license = "MIT"
|
||||||
clap = "2.33.3"
|
clap = "2.33.3"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
|
||||||
[dependencies.nut-client]
|
[dependencies.rups]
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
path = "../nut-client"
|
path = "../rups"
|
||||||
features = ["ssl"]
|
features = ["ssl"]
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
# rupsc
|
# rupsc
|
||||||
|
|
||||||
[](https://crates.io/crates/rupsc)
|
[](https://crates.io/crates/rupsc)
|
||||||
[](https://docs.rs/nut-client)
|
[](https://docs.rs/rups)
|
||||||
[](./LICENSE)
|
[](./LICENSE)
|
||||||
[](https://github.com/aramperes/nut-client-rs/actions?query=workflow%3ACI)
|
[](https://github.com/aramperes/nut-client-rs/actions?query=workflow%3ACI)
|
||||||
|
|
||||||
A Rust clone of [upsc](https://networkupstools.org/docs/man/upsc.html),
|
A Rust clone of [upsc](https://networkupstools.org/docs/man/upsc.html),
|
||||||
the [Network UPS Tools](https://github.com/networkupstools/nut) (NUT) demo program to display UPS variables.
|
the [Network UPS Tools](https://github.com/networkupstools/nut) (NUT) demo program to display UPS variables.
|
||||||
|
|
||||||
Written using the [nut-client](https://github.com/aramperes/nut-client-rs) crate.
|
Written using the [rups](https://github.com/aramperes/nut-client-rs) crate.
|
||||||
|
|
||||||
- Connect to `upsd`/`nut-server` using TCP
|
- Connect to `upsd`/`nut-server` using TCP
|
||||||
- List UPS devices
|
- List UPS devices
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
|
||||||
use nut_client::blocking::Connection;
|
use rups::blocking::Connection;
|
||||||
use nut_client::Config;
|
use rups::Config;
|
||||||
|
|
||||||
/// Lists each UPS on the upsd server, one per line.
|
/// Lists each UPS on the upsd server, one per line.
|
||||||
pub fn list_devices(config: Config, with_description: bool) -> anyhow::Result<()> {
|
pub fn list_devices(config: Config, with_description: bool) -> anyhow::Result<()> {
|
||||||
|
|
|
@ -82,7 +82,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
let ssl = insecure_ssl || args.is_present("ssl");
|
let ssl = insecure_ssl || args.is_present("ssl");
|
||||||
|
|
||||||
let host = server.try_into()?;
|
let host = server.try_into()?;
|
||||||
let config = nut_client::ConfigBuilder::new()
|
let config = rups::ConfigBuilder::new()
|
||||||
.with_host(host)
|
.with_host(host)
|
||||||
.with_debug(debug)
|
.with_debug(debug)
|
||||||
.with_ssl(ssl)
|
.with_ssl(ssl)
|
||||||
|
|
|
@ -64,10 +64,10 @@ impl<'a> TryFrom<&'a str> for UpsdName<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TryInto<nut_client::Host> for UpsdName<'a> {
|
impl<'a> TryInto<rups::Host> for UpsdName<'a> {
|
||||||
type Error = anyhow::Error;
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
fn try_into(self) -> anyhow::Result<nut_client::Host> {
|
fn try_into(self) -> anyhow::Result<rups::Host> {
|
||||||
(self.hostname.to_owned(), self.port)
|
(self.hostname.to_owned(), self.port)
|
||||||
.try_into()
|
.try_into()
|
||||||
.with_context(|| "Invalid hostname/port")
|
.with_context(|| "Invalid hostname/port")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue