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