diff --git a/Cargo.lock b/Cargo.lock index af7e01c..30e624c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,18 +171,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nut-client" -version = "0.4.0" -dependencies = [ - "rustls", - "shell-words", - "tokio", - "tokio-rustls", - "webpki", - "webpki-roots", -] - [[package]] name = "once_cell" version = "1.8.0" @@ -228,13 +216,25 @@ dependencies = [ "winapi", ] +[[package]] +name = "rups" +version = "0.5.0" +dependencies = [ + "rustls", + "shell-words", + "tokio", + "tokio-rustls", + "webpki", + "webpki-roots", +] + [[package]] name = "rupsc" -version = "0.4.0" +version = "0.5.0" dependencies = [ "anyhow", "clap", - "nut-client", + "rups", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 4ceb55c..2078fef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] members = [ - "nut-client", + "rups", "rupsc" ] diff --git a/README.md b/README.md index 6973951..6922cfd 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# nut-client +# rups -[![crates.io](https://img.shields.io/crates/v/nut-client.svg)](https://crates.io/crates/nut-client) -[![Documentation](https://docs.rs/nut-client/badge.svg)](https://docs.rs/nut-client) -[![MIT licensed](https://img.shields.io/crates/l/nut-client.svg)](./LICENSE) +[![crates.io](https://img.shields.io/crates/v/rups.svg)](https://crates.io/crates/rups) +[![Documentation](https://docs.rs/rups/badge.svg)](https://docs.rs/rups) +[![MIT licensed](https://img.shields.io/crates/l/rups.svg)](./LICENSE) [![CI](https://github.com/aramperes/nut-client-rs/workflows/CI/badge.svg)](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. @@ -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`). 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 -// nut-client/examples/blocking.rs +// rups/examples/blocking.rs use std::env; -use nut_client::blocking::Connection; -use nut_client::{Auth, ConfigBuilder}; +use rups::blocking::Connection; +use rups::{Auth, ConfigBuilder}; use std::convert::TryInto; 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) -The `nut-client` library supports async network requests. This requires the `async` feature, which uses Tokio v1 under -the hood. +The `rups` library supports async network requests. This requires the `async` feature, which uses Tokio v1 under the +hood. For SSL support, you must use the `async-ssl` feature as well. + +## Pronunciation + +> r-oops diff --git a/nut-client/Cargo.toml b/rups/Cargo.toml similarity index 92% rename from nut-client/Cargo.toml rename to rups/Cargo.toml index 9081cd7..e5ee66d 100644 --- a/nut-client/Cargo.toml +++ b/rups/Cargo.toml @@ -1,13 +1,13 @@ [package] -name = "nut-client" -version = "0.4.0" +name = "rups" +version = "0.5.0" authors = ["Aram Peres "] edition = "2018" description = "Network UPS Tools (NUT) client library" categories = ["network-programming"] keywords = ["ups", "nut", "tokio", "async"] repository = "https://github.com/aramperes/nut-client-rs" -documentation = "https://docs.rs/nut-client" +documentation = "https://docs.rs/rups" readme = "../README.md" license = "MIT" diff --git a/nut-client/examples/async.rs b/rups/examples/async.rs similarity index 95% rename from nut-client/examples/async.rs rename to rups/examples/async.rs index ce02f89..58b5f6c 100644 --- a/nut-client/examples/async.rs +++ b/rups/examples/async.rs @@ -1,11 +1,11 @@ use std::env; -use nut_client::tokio::Connection; -use nut_client::{Auth, ConfigBuilder}; +use rups::tokio::Connection; +use rups::{Auth, ConfigBuilder}; use std::convert::TryInto; #[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 port = env::var("NUT_PORT") .ok() diff --git a/nut-client/examples/blocking.rs b/rups/examples/blocking.rs similarity index 95% rename from nut-client/examples/blocking.rs rename to rups/examples/blocking.rs index 2dba977..8b1ff67 100644 --- a/nut-client/examples/blocking.rs +++ b/rups/examples/blocking.rs @@ -1,10 +1,10 @@ use std::convert::TryInto; use std::env; -use nut_client::blocking::Connection; -use nut_client::{Auth, ConfigBuilder}; +use rups::blocking::Connection; +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 port = env::var("NUT_PORT") .ok() diff --git a/nut-client/src/blocking/mod.rs b/rups/src/blocking/mod.rs similarity index 100% rename from nut-client/src/blocking/mod.rs rename to rups/src/blocking/mod.rs diff --git a/nut-client/src/blocking/stream.rs b/rups/src/blocking/stream.rs similarity index 100% rename from nut-client/src/blocking/stream.rs rename to rups/src/blocking/stream.rs diff --git a/nut-client/src/cmd.rs b/rups/src/cmd.rs similarity index 100% rename from nut-client/src/cmd.rs rename to rups/src/cmd.rs diff --git a/nut-client/src/config.rs b/rups/src/config.rs similarity index 100% rename from nut-client/src/config.rs rename to rups/src/config.rs diff --git a/nut-client/src/error.rs b/rups/src/error.rs similarity index 100% rename from nut-client/src/error.rs rename to rups/src/error.rs diff --git a/nut-client/src/lib.rs b/rups/src/lib.rs similarity index 80% rename from nut-client/src/lib.rs rename to rups/src/lib.rs index 7877811..33cd610 100644 --- a/nut-client/src/lib.rs +++ b/rups/src/lib.rs @@ -1,8 +1,8 @@ #![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. pub use config::*; diff --git a/nut-client/src/ssl/mod.rs b/rups/src/ssl/mod.rs similarity index 100% rename from nut-client/src/ssl/mod.rs rename to rups/src/ssl/mod.rs diff --git a/nut-client/src/tokio/mod.rs b/rups/src/tokio/mod.rs similarity index 100% rename from nut-client/src/tokio/mod.rs rename to rups/src/tokio/mod.rs diff --git a/nut-client/src/tokio/stream.rs b/rups/src/tokio/stream.rs similarity index 100% rename from nut-client/src/tokio/stream.rs rename to rups/src/tokio/stream.rs diff --git a/nut-client/src/var.rs b/rups/src/var.rs similarity index 100% rename from nut-client/src/var.rs rename to rups/src/var.rs diff --git a/rupsc/Cargo.toml b/rupsc/Cargo.toml index 24c3388..42dbc86 100644 --- a/rupsc/Cargo.toml +++ b/rupsc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rupsc" -version = "0.4.0" +version = "0.5.0" authors = ["Aram Peres "] edition = "2018" description = "A demo program to display UPS variables" @@ -16,7 +16,7 @@ license = "MIT" clap = "2.33.3" anyhow = "1" -[dependencies.nut-client] -version = "0.4.0" -path = "../nut-client" +[dependencies.rups] +version = "0.5.0" +path = "../rups" features = ["ssl"] diff --git a/rupsc/README.md b/rupsc/README.md index cb6cd4d..0ee10f1 100644 --- a/rupsc/README.md +++ b/rupsc/README.md @@ -1,14 +1,14 @@ # rupsc [![crates.io](https://img.shields.io/crates/v/rupsc.svg)](https://crates.io/crates/rupsc) -[![Documentation](https://docs.rs/nut-client/badge.svg)](https://docs.rs/nut-client) +[![Documentation](https://docs.rs/rups/badge.svg)](https://docs.rs/rups) [![MIT licensed](https://img.shields.io/crates/l/rupsc.svg)](./LICENSE) [![CI](https://github.com/aramperes/nut-client-rs/workflows/CI/badge.svg)](https://github.com/aramperes/nut-client-rs/actions?query=workflow%3ACI) 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. -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 - List UPS devices diff --git a/rupsc/src/cmd.rs b/rupsc/src/cmd.rs index 29850d1..4d13ad9 100644 --- a/rupsc/src/cmd.rs +++ b/rupsc/src/cmd.rs @@ -1,7 +1,7 @@ use anyhow::Context; -use nut_client::blocking::Connection; -use nut_client::Config; +use rups::blocking::Connection; +use rups::Config; /// Lists each UPS on the upsd server, one per line. pub fn list_devices(config: Config, with_description: bool) -> anyhow::Result<()> { diff --git a/rupsc/src/main.rs b/rupsc/src/main.rs index 58fb2af..2dd16af 100644 --- a/rupsc/src/main.rs +++ b/rupsc/src/main.rs @@ -82,7 +82,7 @@ fn main() -> anyhow::Result<()> { let ssl = insecure_ssl || args.is_present("ssl"); let host = server.try_into()?; - let config = nut_client::ConfigBuilder::new() + let config = rups::ConfigBuilder::new() .with_host(host) .with_debug(debug) .with_ssl(ssl) diff --git a/rupsc/src/parser.rs b/rupsc/src/parser.rs index 0afb2d4..ceb7d69 100644 --- a/rupsc/src/parser.rs +++ b/rupsc/src/parser.rs @@ -64,10 +64,10 @@ impl<'a> TryFrom<&'a str> for UpsdName<'a> { } } -impl<'a> TryInto for UpsdName<'a> { +impl<'a> TryInto for UpsdName<'a> { type Error = anyhow::Error; - fn try_into(self) -> anyhow::Result { + fn try_into(self) -> anyhow::Result { (self.hostname.to_owned(), self.port) .try_into() .with_context(|| "Invalid hostname/port")