January 2018
Beginner to intermediate
454 pages
10h 8m
English
To handle the commands received by the FTP server, we'll have a Client struct:
type Writer = SplitSink<Framed<TcpStream, FtpCodec>>; struct Client { writer: Writer, }
The client contains a Writer object that will be useful to send messages to the client. The Writer type represents a Sink that has been split, and uses the FtpCodec on a TcpStream. A Sink is the opposite of a Stream: instead of representing a sequence of values that are received, it represents a sequence of values that are sent.
We used two methods on Client, so let's write them:
use cmd::Command; impl Client { fn new(writer: Writer) -> Client { Client { writer, } } #[async] fn handle_cmd(mut self, cmd: Command) -> Result<Self> { Ok(self) } }
The constructor ...
Read now
Unlock full access