use crate::Error;
use crate::FormatsOutput;
use std::str::FromStr;
#[derive(Default, PartialEq, Clone, Debug)]
pub struct Client {
#[cfg(feature = "tmux_1_6")]
pub activity: Option<u128>,
#[cfg(feature = "tmux_3_1")]
pub cell_height: Option<usize>,
#[cfg(feature = "tmux_3_1")]
pub cell_width: Option<usize>,
#[cfg(all(feature = "tmux_1_6", not(feature = "tmux_2_2")))]
pub activity_string: Option<String>,
#[cfg(feature = "tmux_1_6")]
pub created: Option<u128>,
#[cfg(all(feature = "tmux_1_6", not(feature = "tmux_2_2")))]
pub created_string: Option<String>,
#[cfg(feature = "tmux_2_1")]
pub control_mode: Option<bool>,
#[cfg(feature = "tmux_2_1")]
pub discarded: Option<String>,
#[cfg(all(feature = "tmux_1_6", not(feature = "tmux_1_9")))]
pub cwd: Option<String>,
#[cfg(feature = "tmux_1_6")]
pub height: Option<usize>,
#[cfg(feature = "tmux_2_2")]
pub key_table: Option<String>,
#[cfg(feature = "tmux_1_8")]
pub last_session: Option<String>,
#[cfg(feature = "tmux_2_4")]
pub name: Option<String>,
#[cfg(feature = "tmux_2_1")]
pub pid: Option<usize>,
#[cfg(feature = "tmux_1_8")]
pub prefix: Option<bool>,
#[cfg(feature = "tmux_1_6")]
pub readonly: Option<bool>,
#[cfg(feature = "tmux_1_8")]
pub session: Option<String>,
#[cfg(feature = "tmux_1_6")]
pub termname: Option<String>,
#[cfg(all(feature = "tmux_2_4", not(feature = "tmux_3_1")))]
pub termtype: Option<String>,
#[cfg(feature = "tmux_1_6")]
pub tty: Option<String>,
#[cfg(feature = "tmux_1_6")]
pub utf8: Option<bool>,
#[cfg(feature = "tmux_1_6")]
pub width: Option<usize>,
#[cfg(feature = "tmux_2_4")]
pub written: Option<usize>,
}
impl FromStr for Client {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
let mut client = Client::new();
let mut format = FormatsOutput::new();
format.separator(':');
#[cfg(feature = "tmux_1_6")]
format.client_activity(&mut client.activity);
#[cfg(feature = "tmux_3_1")]
format.client_cell_height(&mut client.cell_height);
#[cfg(feature = "tmux_3_1")]
format.client_cell_width(&mut client.cell_width);
#[cfg(all(feature = "tmux_1_6", not(feature = "tmux_2_2")))]
format.client_activity_string(&mut client.activity_string);
#[cfg(feature = "tmux_1_6")]
format.client_created(&mut client.created);
#[cfg(all(feature = "tmux_1_6", not(feature = "tmux_2_2")))]
format.client_created_string(&mut client.created_string);
#[cfg(feature = "tmux_2_1")]
format.client_control_mode(&mut client.control_mode);
#[cfg(feature = "tmux_2_1")]
format.client_discarded(&mut client.discarded);
#[cfg(all(feature = "tmux_1_6", not(feature = "tmux_1_9")))]
format.client_cwd(&mut client.cwd);
#[cfg(feature = "tmux_1_6")]
format.client_height(&mut client.height);
#[cfg(feature = "tmux_2_2")]
format.client_key_table(&mut client.key_table);
#[cfg(feature = "tmux_1_8")]
format.client_last_session(&mut client.last_session);
#[cfg(feature = "tmux_2_4")]
format.client_name(&mut client.name);
#[cfg(feature = "tmux_2_1")]
format.client_pid(&mut client.pid);
#[cfg(feature = "tmux_1_8")]
format.client_prefix(&mut client.prefix);
#[cfg(feature = "tmux_1_6")]
format.client_readonly(&mut client.readonly);
#[cfg(feature = "tmux_1_8")]
format.client_session(&mut client.session);
#[cfg(feature = "tmux_1_6")]
format.client_termname(&mut client.termname);
#[cfg(all(feature = "tmux_2_4", not(feature = "tmux_3_1")))]
format.client_termtype(&mut client.termtype);
#[cfg(feature = "tmux_1_6")]
format.client_tty(&mut client.tty);
#[cfg(feature = "tmux_1_6")]
format.client_utf8(&mut client.utf8);
#[cfg(feature = "tmux_1_6")]
format.client_width(&mut client.width);
#[cfg(feature = "tmux_2_4")]
format.client_written(&mut client.written);
FormatsOutput::from_string_ext(s, &mut format);
Ok(client)
}
}
impl Client {
pub fn new() -> Self {
Default::default()
}
}