mirror of
https://github.com/aramperes/nut-rs.git
synced 2025-09-08 21:18:31 -04:00
parent
77d3020df5
commit
c56be76906
3 changed files with 21 additions and 0 deletions
|
@ -25,6 +25,11 @@ async fn main() -> nut_client::Result<()> {
|
||||||
|
|
||||||
let mut conn = Connection::new(&config).await?;
|
let mut conn = Connection::new(&config).await?;
|
||||||
|
|
||||||
|
// Get server information
|
||||||
|
println!("NUT server:");
|
||||||
|
println!("\tVersion: {}", conn.get_server_version().await?);
|
||||||
|
println!("\tNetwork Version: {}", conn.get_network_version().await?);
|
||||||
|
|
||||||
// Print a list of all UPS devices
|
// Print a list of all UPS devices
|
||||||
println!("Connected UPS devices:");
|
println!("Connected UPS devices:");
|
||||||
for (name, description) in conn.list_ups().await? {
|
for (name, description) in conn.list_ups().await? {
|
||||||
|
|
|
@ -24,6 +24,11 @@ fn main() -> nut_client::Result<()> {
|
||||||
|
|
||||||
let mut conn = Connection::new(&config)?;
|
let mut conn = Connection::new(&config)?;
|
||||||
|
|
||||||
|
// Get server information
|
||||||
|
println!("NUT server:");
|
||||||
|
println!("\tVersion: {}", conn.get_server_version()?);
|
||||||
|
println!("\tNetwork Version: {}", conn.get_network_version()?);
|
||||||
|
|
||||||
// Print a list of all UPS devices
|
// Print a list of all UPS devices
|
||||||
println!("Connected UPS devices:");
|
println!("Connected UPS devices:");
|
||||||
for (name, description) in conn.list_ups()? {
|
for (name, description) in conn.list_ups()? {
|
||||||
|
|
|
@ -15,6 +15,8 @@ pub enum Command<'a> {
|
||||||
StartTLS,
|
StartTLS,
|
||||||
/// Queries the network version.
|
/// Queries the network version.
|
||||||
NetworkVersion,
|
NetworkVersion,
|
||||||
|
/// Queries the server version
|
||||||
|
Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Command<'a> {
|
impl<'a> Command<'a> {
|
||||||
|
@ -27,6 +29,7 @@ impl<'a> Command<'a> {
|
||||||
Self::List(_) => "LIST",
|
Self::List(_) => "LIST",
|
||||||
Self::StartTLS => "STARTTLS",
|
Self::StartTLS => "STARTTLS",
|
||||||
Self::NetworkVersion => "NETVER",
|
Self::NetworkVersion => "NETVER",
|
||||||
|
Self::Version => "VER",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,6 +483,14 @@ implement_simple_commands! {
|
||||||
{ |row: String| Ok(row) },
|
{ |row: String| Ok(row) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Queries the server NUT version.
|
||||||
|
pub fn get_server_version() -> String {
|
||||||
|
(
|
||||||
|
{ Command::Version },
|
||||||
|
{ |row: String| Ok(row) },
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implement_action_commands! {
|
implement_action_commands! {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue