1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
use crate::server::{
controlchan::commands::{AuthParam, ModeParam, Opt, ProtParam, StruParam},
password::Password,
};
use bytes::Bytes;
use std::{fmt, path::PathBuf};
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Command {
User {
/// The bytes making up the actual username.
username: Bytes,
},
Pass {
/// The bytes making up the actual password.
password: Password,
},
Acct {
/// The bytes making up the account about which information is requested.
account: Bytes,
},
Syst,
Stat {
/// The bytes making up the path about which information is requested, if given.
path: Option<Bytes>,
},
Type,
Stru {
/// The structure to which the client would like to switch. Only the `File` structure is
/// supported by us.
structure: StruParam,
},
Mode {
/// The transfer mode to which the client would like to switch. Only the `Stream` mode is
/// supported by us.
mode: ModeParam,
},
Help,
Noop,
Pasv,
Epsv,
Port {
/// The address to use to make an active connection to the client
addr: String,
},
Retr {
/// The path to the file the client would like to retrieve.
path: String,
},
Stor {
/// The path to the file the client would like to store.
path: String,
},
Appe {
/// The path to the file the client would like to append to.
path: String,
},
List {
/// Arguments passed along with the list command.
options: Option<String>,
/// The path of the file/directory the clients wants to list
path: Option<String>,
},
Nlst {
/// The path of the file/directory the clients wants to list.
path: Option<String>,
},
/// Machine List Single (MLST) command for getting machine-readable information about a single file/directory
Mlst {
/// The path of the file/directory to get information about
path: Option<String>,
},
/// Machine List Directory (MLSD) command for getting machine-readable information about directory contents
Mlsd {
/// The path of the directory to list
path: Option<String>,
},
Feat,
Pwd,
Cwd {
/// The path the client would like to change directory to.
path: PathBuf,
},
Cdup,
Opts {
/// The option the client wants to set
option: Opt,
},
Dele {
/// The (regular) file to delete.
path: String,
},
Rmd {
/// The (regular) directory to delete.
path: String,
},
Quit,
Mkd {
/// The path to the directory the client wants to create.
path: PathBuf,
},
Allo {
// The `ALLO` command can actually have an optional argument, but since we regard `ALLO`
// as noop, we won't even parse it.
},
Abor,
Stou,
Rnfr {
/// The file to be renamed
file: PathBuf,
},
Rnto {
/// The filename to rename to
file: PathBuf,
},
Auth {
protocol: AuthParam,
},
Ccc,
Pbsz {},
Prot {
param: ProtParam,
},
Size {
file: PathBuf,
},
Rest {
offset: u64,
},
/// Modification Time (MDTM) as specified in RFC 3659.
/// This command can be used to determine when a file in the server NVFS was last modified.
Mdtm {
file: PathBuf,
},
Md5 {
file: PathBuf,
},
Other {
command_name: String,
arguments: String,
},
}
impl fmt::Display for Command {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}