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