SuppaFTP
Introduction 👋
SuppaFTP is a feature-rich FTP/FTPS client library for Rust, supporting both synchronous and asynchronous programming. It aims to be a complete, reliable and well-tested implementation of the FTP protocol for Rust developers.
Features ✨
- 🔒 FTPS support with your choice of TLS backend: native-tls or rustls
- 🕙 First-class sync and async APIs, with tokio and async-std as async backends
- ⬇️ Stream-based transfers (e.g.
put_with_stream,retr) for fine-grained control over data connections - ↔️ Both passive and active transfer modes
- 🌟 Wide command coverage, including
ABOR,APPE,REST,EPSVandEPRT - 📑 Built-in parser for the LIST command output (POSIX and DOS formats) into structured
Fileobjects - 👋 Helpers such as
get_welcome_msgto access server greetings - 🦀 Pure Rust with no mandatory C bindings (when using rustls)
- 📜 Implements RFC 2428 and RFC 2389
- 🐛 Robust error handling and an extensive test suite with code coverage
Get started 🏁
To get started, first add suppaftp to your dependencies:
= "^8"
Cargo features
These are all the possible features, by family
- Sync FTP:
native-tls: enable FTPS support using native-tls as backend for TLSnative-tls-vendored: enable vendored FTPS support using native-tlsrustls-aws-lc-rs: enable FTPS support using rustls with aws-lc-rs as TLS backend.rustls-ring: enable FTPS support using rustls with ring as TLS backend.
- Async FTP:
- Async-std:
async-std: enable async client using async-std as async backendasync-std-async-native-tls: enable FTPS support using async-native-tlsasync-std-async-native-tls-vendored: enable vendored FTPS support using async-native-tlsasync-std-rustls-aws-lc-rs: enable FTPS support using rustls with aws-lc-rs as TLS backend.async-std-rustls-ring: enable FTPS support using rustls with ring as TLS backend.
- Tokio:
tokio: enable async client using tokio as async backendtokio-async-native-tls: enable FTPS support using async-native-tlstokio-async-native-tls-vendored: enable vendored FTPS support using async-native-tlstokio-rustls-aws-lc-rs: enable FTPS support using rustls with aws-lc-rs as TLS backend.tokio-rustls-ring: enable FTPS support using rustls with ring as TLS backend.
- Async-std:
- Misc:
deprecated: enable deprecated FTP/FTPS methodsno-log: disable logging
In more details:
SSL/TLS Support
If you want to enable support for FTPS, you must enable the native-tls or one of the rustls features in your
cargo dependencies, based on the TLS provider you prefer.
= { = "^8", = ["native-tls"] }
# or
= { = "^8", = ["rustls-aws-lc-rs"] }
[!NOTE] 💡 If you don't know what to choose,
native-tlsshould be preferred for compatibility reasons.
❗ If you want to link libssl statically, enable featurenative-tls-vendored
Async support
If you want to enable async support, you must enable either async-std feature, to
use async-std or tokio feature, to use tokio
as backend, in your cargo dependencies.
= { = "^8", = ["tokio"] }
[!CAUTION] ⚠️ To enable both native-tls and async-std, use the async-std-async-native-tls feature ⚠️
⚠️ To enable both native-tls and tokio, use the tokio-async-native-tls feature ⚠️
⚠️ To enable both rustls and async-std, use the async-std-rustls-aws-lc-rs (or-ring) feature ⚠️
⚠️ To enable both rustls and tokio, use the tokio-rustls-aws-lc-rs (or-ring) feature ⚠️
❗ To link libssl statically withasync-std, enable featureasync-std-async-native-tls-vendored
❗ To link libssl statically withtokio, enable featuretokio-async-native-tls-vendored
Deprecated methods
If you want to enable deprecated methods of FTPS, please enable the deprecated feature in your cargo dependencies.
This feature enables these methods:
connect_secure_implicit(): used to connect via implicit FTPS
Logging
By default, the library will log if there is any log crate consumer on the user implementation.
Logging can be if preferred, disabled via the no-log feature.
Examples 📚
use Cursor;
use str;
use FtpStream;
Ftp with TLS (native-tls)
use TlsConnector;
use ;
Ftp with TLS (rustls)
You can also find and run this example in the suppaftp/examples/ directory (
cargo run --example rustls --features rustls).
use Arc;
use ClientConfig;
use ;
Going Async
use TlsConnector;
use ;
async
Built-in CLI client 🖥️
SuppaFTP comes also with a built-in command-line FTP client. This CLI application provides all the commands to interact
with a remote FTP server and supports FTPS too. You can also use it as a reference to implement your project. You can
find it in the crates/suppaftp-cli/ directory.
You can simply install as any other rust application via Cargo:
Changelog ⌛
License 📜
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution 🤝
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
If you want to contribute to this project, please read the Contributing guide first 🙂.