Setting the transfer type
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 through FileZilla, we'll see the following:
Figure 9.3