pub struct ClientBuilder { /* private fields */ }Expand description
Tokio-based asynchronous client API.
This is the default mode (feature async).
Builder for Client.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new(target: SocketAddr) -> Self
pub fn new(target: SocketAddr) -> Self
Create a new builder.
Sourcepub fn username_bytes(self, username: impl Into<Vec<u8>>) -> Self
pub fn username_bytes(self, username: impl Into<Vec<u8>>) -> Self
Set the username (bytes).
IPMI usernames are ASCII in most deployments, but the protocol treats them as raw bytes.
Sourcepub fn username(self, username: impl AsRef<str>) -> Self
pub fn username(self, username: impl AsRef<str>) -> Self
Set the username (UTF-8 string). This is a convenience wrapper around Self::username_bytes.
Examples found in repository?
8 pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 // Example:
10 // cargo run --example tokio_get_device_id -- 192.168.1.10:623 admin password
11 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 }Sourcepub fn password_bytes(self, password: impl Into<Vec<u8>>) -> Self
pub fn password_bytes(self, password: impl Into<Vec<u8>>) -> Self
Set the password (bytes).
Sourcepub fn password(self, password: impl AsRef<str>) -> Self
pub fn password(self, password: impl AsRef<str>) -> Self
Set the password (UTF-8 string). This is a convenience wrapper around Self::password_bytes.
Examples found in repository?
8 pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 // Example:
10 // cargo run --example tokio_get_device_id -- 192.168.1.10:623 admin password
11 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 }Sourcepub fn bmc_key_bytes(self, kg: impl Into<Vec<u8>>) -> Self
pub fn bmc_key_bytes(self, kg: impl Into<Vec<u8>>) -> Self
Set the optional BMC key (Kg) for “two-key” logins.
If not set, the password key is used (“one-key” login), which is common in many BMC default configs.
Sourcepub fn bmc_key(self, kg: impl AsRef<str>) -> Self
pub fn bmc_key(self, kg: impl AsRef<str>) -> Self
Set the optional BMC key (Kg) for “two-key” logins (UTF-8 string).
Sourcepub fn privilege_level(self, level: PrivilegeLevel) -> Self
pub fn privilege_level(self, level: PrivilegeLevel) -> Self
Set requested session privilege level.
Examples found in repository?
8 pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 // Example:
10 // cargo run --example tokio_get_device_id -- 192.168.1.10:623 admin password
11 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 }Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Set UDP read timeout.
Examples found in repository?
8 pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 // Example:
10 // cargo run --example tokio_get_device_id -- 192.168.1.10:623 admin password
11 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 }Sourcepub fn retries(self, attempts: u32) -> Self
pub fn retries(self, attempts: u32) -> Self
Set number of send attempts per request (including the first attempt).
Examples found in repository?
8 pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 // Example:
10 // cargo run --example tokio_get_device_id -- 192.168.1.10:623 admin password
11 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 }Sourcepub async fn build(self) -> Result<Client>
pub async fn build(self) -> Result<Client>
Establish the session and build the Client.
Examples found in repository?
8 pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 // Example:
10 // cargo run --example tokio_get_device_id -- 192.168.1.10:623 admin password
11 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 }