January 2018
Beginner to intermediate
454 pages
10h 8m
English
Let's add a new command before we test our server again:
use cmd::TransferType;
#[async]
fn handle_cmd(mut self, cmd: Command) -> Result<Self> {
match cmd {
// …
Command::Type(typ) => {
self.transfer_type = typ;
self = await!(self.send(Answer::new(ResultCode::Ok, "Transfer type changed successfully")))?;
}
// …
}
}
This requires a new attribute for our Client structure:
struct Client { cwd: PathBuf, server_root: PathBuf, transfer_type: TransferType, writer: Writer, }
And we need to update the constructor:
impl Client { fn new(writer: Writer, server_root: PathBuf) -> Client { Client { cwd: PathBuf::from("/"), server_root, transfer_type: TransferType::Ascii, writer, } } }
If we run this new server and connect to it ...