1use std::fmt;
2use std::fmt::Formatter;
3use std::path::Display;
4
5#[derive(Debug)]
6pub enum Command {
7 ABOR,
8 ACCT,
9 ALLO,
10 APPE,
11 CDUP,
12 CWD,
13 DELE,
14 EPRT,
15 EPSV,
16 FEAT,
17 HELP,
18 LIST,
19 MDTM,
20 MFMT,
21 MKD,
22 MLSD,
23 MLST,
24 MODE,
25 NLST,
26 NOOP,
27 PASS,
28 PASV,
29 PORT,
30 PWD,
31 QUIT,
32 REIN,
33 REST,
34 RETR,
35 RMD,
36 RNFR,
37 RNTO,
38 SITE,
39 SIZE,
40 SMNT,
41 STAT,
42 STOR,
43 STOU,
44 STRU,
45 SYST,
46 TYPE,
47 USER,
48
49 #[cfg(feature = "ftps")]
50 AUTH,
51
52 #[cfg(feature = "ftps")]
53 ADAT,
54
55 #[cfg(feature = "ftps")]
56 PROT,
57
58 #[cfg(feature = "ftps")]
59 PBSZ,
60
61 #[cfg(feature = "ftps")]
62 MIC,
63
64 #[cfg(feature = "ftps")]
65 CONF,
66
67 #[cfg(feature = "ftps")]
68 ENC,
69
70 #[cfg(feature = "ftps")]
71 CCC,
72}
73
74impl Command {
75 pub(crate) fn cmd_name(&self) -> &str {
77 match self {
78 Command::ABOR => "ABOR",
79 Command::ACCT => "ACCT",
80 Command::ALLO => "ALLO",
81 Command::APPE => "APPE",
82 Command::CDUP => "CDUP",
83 Command::CWD => "CWD",
84 Command::DELE => "DELE",
85 Command::EPRT => "EPRT",
86 Command::EPSV => "EPSV",
87 Command::FEAT => "FEAT",
88 Command::HELP => "HELP",
89 Command::LIST => "LIST",
90 Command::MDTM => "MDTM",
91 Command::MFMT => "MFMT",
92 Command::MKD => "MKD",
93 Command::MLSD => "MLSD",
94 Command::MLST => "MLST",
95 Command::MODE => "MODE",
96 Command::NLST => "NLST",
97 Command::NOOP => "NOOP",
98 Command::PASS => "PASS",
99 Command::PASV => "PASV",
100 Command::PORT => "PORT",
101 Command::PWD => "PWD",
102 Command::QUIT => "QUIT",
103 Command::REIN => "REIN",
104 Command::REST => "REST",
105 Command::RETR => "RETR",
106 Command::RMD => "RMD",
107 Command::RNTO => "RNTO",
108 Command::SIZE => "SIZE",
109 Command::SITE => "SITE",
110 Command::SMNT => "SMNT",
111 Command::STAT => "STAT",
112 Command::STOR => "STOR",
113 Command::STOU => "STOU",
114 Command::STRU => "STRU",
115 Command::SYST => "SYST",
116 Command::TYPE => "TYPE",
117 Command::USER => "USER",
118
119 #[cfg(feature = "ftps")]
120 Command::AUTH => "AUTH",
121 #[cfg(feature = "ftps")]
122 Command::ADAT => "ADAT",
123 #[cfg(feature = "ftps")]
124 Command::PROT => "PROT",
125 #[cfg(feature = "ftps")]
126 Command::PBSZ => "PBSZ",
127 #[cfg(feature = "ftps")]
128 Command::MIC => "MIC",
129 #[cfg(feature = "ftps")]
130 Command::CONF => "CONF",
131 #[cfg(feature = "ftps")]
132 Command::ENC => "ENC",
133 #[cfg(feature = "ftps")]
134 Command::CCC => "CCC",
135 _ => { "Unknown" }
136 }
137 }
138}
139
140impl fmt::Display for Command {
141 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
142 write!(f, "{}", self.cmd_name())
143 }
144}