ClientBuilder

Struct ClientBuilder 

Source
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

Source

pub fn new(target: SocketAddr) -> Self

Create a new builder.

Source

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.

Source

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?
examples/tokio_get_device_id.rs (line 17)
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    }
Source

pub fn password_bytes(self, password: impl Into<Vec<u8>>) -> Self

Set the password (bytes).

Source

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?
examples/tokio_get_device_id.rs (line 18)
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    }
Source

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.

Source

pub fn bmc_key(self, kg: impl AsRef<str>) -> Self

Set the optional BMC key (Kg) for “two-key” logins (UTF-8 string).

Source

pub fn privilege_level(self, level: PrivilegeLevel) -> Self

Set requested session privilege level.

Examples found in repository?
examples/tokio_get_device_id.rs (line 19)
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    }
Source

pub fn timeout(self, timeout: Duration) -> Self

Set UDP read timeout.

Examples found in repository?
examples/tokio_get_device_id.rs (line 20)
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    }
Source

pub fn retries(self, attempts: u32) -> Self

Set number of send attempts per request (including the first attempt).

Examples found in repository?
examples/tokio_get_device_id.rs (line 21)
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    }
Source

pub async fn build(self) -> Result<Client>

Establish the session and build the Client.

Examples found in repository?
examples/tokio_get_device_id.rs (line 22)
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    }

Trait Implementations§

Source§

impl Debug for ClientBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V