use crate::commons::{Username, VirtualHostName};
#[cfg(feature = "tabled")]
use crate::formatting::display_option;
use serde::Deserialize;
#[cfg(feature = "tabled")]
use tabled::Tabled;
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct Connection {
pub name: String,
pub node: String,
#[cfg_attr(feature = "tabled", tabled(display = "display_option"))]
pub state: Option<String>,
pub protocol: String,
#[serde(rename(deserialize = "user"))]
pub username: Username,
pub connected_at: u64,
#[serde(rename(deserialize = "host"))]
#[cfg_attr(feature = "tabled", tabled(display = "display_option"))]
pub server_hostname: Option<String>,
#[serde(rename(deserialize = "port"))]
#[cfg_attr(feature = "tabled", tabled(display = "display_option"))]
pub server_port: Option<u32>,
#[serde(rename(deserialize = "peer_host"))]
#[cfg_attr(feature = "tabled", tabled(display = "display_option"))]
pub client_hostname: Option<String>,
#[serde(rename(deserialize = "peer_port"))]
#[cfg_attr(feature = "tabled", tabled(display = "display_option"))]
pub client_port: Option<u32>,
#[cfg_attr(feature = "tabled", tabled(display = "display_option"))]
pub channel_max: Option<u16>,
#[serde(rename(deserialize = "channels"))]
#[serde(default)]
pub channel_count: u16,
#[cfg_attr(feature = "tabled", tabled(skip))]
pub client_properties: ClientProperties,
}
#[derive(Debug, Deserialize, Clone)]
#[allow(dead_code)]
pub struct ClientProperties {
#[serde(default)]
pub connection_name: String,
#[serde(default)]
pub platform: String,
#[serde(default)]
pub product: String,
#[serde(default)]
pub version: String,
pub capabilities: Option<ClientCapabilities>,
}
#[derive(Debug, Deserialize, Clone)]
#[allow(dead_code)]
pub struct ClientCapabilities {
#[serde(default)]
pub authentication_failure_close: bool,
#[serde(rename(deserialize = "basic.nack"), default)]
pub basic_nack: bool,
#[serde(rename(deserialize = "connection.blocked"), default)]
pub connection_blocked: bool,
#[serde(rename(deserialize = "consumer_cancel_notify"), default)]
pub consumer_cancel_notify: bool,
#[serde(rename(deserialize = "exchange_exchange_bindings"), default)]
pub exchange_to_exchange_bindings: bool,
#[serde(default)]
pub publisher_confirms: bool,
}
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct UserConnection {
pub name: Username,
pub node: String,
#[serde(rename(deserialize = "user"))]
pub username: Username,
pub vhost: VirtualHostName,
}
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct ConnectionDetails {
pub name: String,
#[serde(rename(deserialize = "peer_host"))]
pub client_hostname: String,
#[serde(rename(deserialize = "peer_port"))]
pub client_port: u32,
}