tokio_get_device_id/
tokio_get_device_id.rs1#[cfg(feature = "async")]
2mod enabled {
3 use std::time::Duration;
4
5 use ipmi::{Client, PrivilegeLevel};
6
7 #[tokio::main(flavor = "current_thread")]
8 pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let mut args = std::env::args().skip(1);
12 let target = args.next().ok_or("missing <host:port>")?.parse()?;
13 let username = args.next().ok_or("missing <username>")?;
14 let password = args.next().ok_or("missing <password>")?;
15
16 let client = Client::builder(target)
17 .username(username)
18 .password(password)
19 .privilege_level(PrivilegeLevel::Administrator)
20 .timeout(Duration::from_secs(2))
21 .retries(3)
22 .build()
23 .await?;
24
25 let device_id = client.get_device_id().await?;
26 println!("Device: {device_id:?}");
27
28 Ok(())
29 }
30}
31
32#[cfg(feature = "async")]
33fn main() -> Result<(), Box<dyn std::error::Error>> {
34 enabled::main()
35}
36
37#[cfg(not(feature = "async"))]
38fn main() {
39 eprintln!("This example requires feature `async` (or `tokio`).");
40}