January 2018
Beginner to intermediate
454 pages
10h 8m
English
Since we have a name in our Client structure, it'd be nice to have some use for it, right? So, as the title says, let's implement the USER command. Since this command takes an argument, I'll go through the command implementation steps once again, so you'll have an example of a command taking a parameter.
First, let's update the enum Command:
enum Command {
Auth,
Syst,
User(String),
Unknown(String),
}
Then, we update the as_ref implementation:
impl AsRef<str> for Command {
fn as_ref(&self) -> &str {
match *self {
Command::Auth => "AUTH",
Command::Syst => "SYST",
Command::User => "USER",
Command::Unknown(_) => "UNKN",
}
}
}
Finally, we update the Command::new method:
impl Command { pub fn new(input: Vec<u8>) -> ...Read now
Unlock full access