Another common application layer protocol is the File Transfer Protocol (FTP). This is a text-based protocol, where the server and clients exchange text commands to upload and download files. The Rust ecosystem has a crate called rust-ftp to interact with FTP servers programmatically. Let us look at an example of its use. We set up our project using Cargo:
$ cargo new --bin ftp-example
Our Cargo.toml should look like this:
[package]name = "ftp-example"version = "0.1.0"authors = ["Foo<foo@bar.com>"][dependencies.ftp]version = "2.2.1"
For this example to work, we will need a running FTP server somewhere. Once we have set that up and made sure a regular FTP client can connect to it, we can move on to our main code: ...