tmux_interface/options/session/common/
detach_on_destroy.rs1use crate::options::common::constants::*;
2use crate::Error;
3use std::fmt;
4use std::str::FromStr;
5
6#[cfg(feature = "tmux_1_4")]
7#[derive(PartialEq, Clone, Debug)]
8pub enum DetachOnDestroy {
9 On,
10 Off,
11 #[cfg(feature = "tmux_3_2")]
12 NoDetached,
13}
14
15#[cfg(feature = "tmux_1_4")]
16impl FromStr for DetachOnDestroy {
17 type Err = Error;
18
19 fn from_str(s: &str) -> Result<Self, Error> {
20 match s {
21 ON => Ok(Self::On),
22 OFF => Ok(Self::Off),
23 #[cfg(feature = "tmux_3_2")]
24 NO_DETACHED => Ok(Self::NoDetached),
25 _ => Err(Error::ParseDetachOnDestroy),
26 }
27 }
28}
29
30#[cfg(feature = "tmux_1_4")]
31impl fmt::Display for DetachOnDestroy {
32 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
33 match self {
34 Self::On => write!(f, "{}", ON),
35 Self::Off => write!(f, "{}", OFF),
36 #[cfg(feature = "tmux_3_2")]
37 Self::NoDetached => write!(f, "{}", NO_DETACHED),
38 }
39 }
40}