haproxy_stats_socket/client/
impl_show_info.rs1use core::fmt;
2
3use haproxy_stats::{info::InfoFromKvBytesError, Command, Info};
4
5use super::{Client, ClientSendError};
6
7impl Client {
9 pub async fn show_info(&self) -> Result<Info, ClientShowInfoError> {
10 let response = self
11 .send_async(&Command::show_info())
12 .await
13 .map_err(ClientShowInfoError::ClientSendError)?;
14
15 let info =
16 Info::from_kv_bytes(response).map_err(ClientShowInfoError::ResponseParseError)?;
17
18 Ok(info)
19 }
20}
21
22#[derive(Debug)]
24pub enum ClientShowInfoError {
25 ClientSendError(ClientSendError),
26 ResponseParseError(InfoFromKvBytesError),
27}
28
29impl fmt::Display for ClientShowInfoError {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 write!(f, "{:?}", self)
32 }
33}
34
35impl std::error::Error for ClientShowInfoError {}