ftp/lib.rs
1#![crate_name = "ftp"]
2#![crate_type = "lib"]
3
4//! ftp is an FTP client written in Rust.
5//!
6//! ### Usage
7//!
8//! Here is a basic usage example:
9//!
10//! ```rust
11//! use ftp::FtpStream;
12//! let mut ftp_stream = FtpStream::connect("127.0.0.1:21").unwrap_or_else(|err|
13//! panic!("{}", err)
14//! );
15//! let _ = ftp_stream.quit();
16//! ```
17//!
18//! ### FTPS
19//!
20//! The client supports FTPS on demand. To enable it the client should be
21//! compiled with feature `openssl` enabled what requires
22//! [openssl](https://crates.io/crates/openssl) dependency.
23//!
24//! The client uses explicit mode for connecting FTPS what means you should
25//! connect the server as usually and then switch to the secure mode (TLS is used).
26//! For better security it's the good practice to switch to the secure mode
27//! before authentication.
28//!
29//! ### FTPS Usage
30//!
31//! ```rust,no_run
32//! use ftp::FtpStream;
33//! use ftp::openssl::ssl::{ SslContext, SslMethod };
34//!
35//! let ftp_stream = FtpStream::connect("127.0.0.1:21").unwrap();
36//! let ctx = SslContext::builder(SslMethod::tls()).unwrap().build();
37//! // Switch to the secure mode
38//! let mut ftp_stream = ftp_stream.into_secure(ctx).unwrap();
39//! ftp_stream.login("anonymous", "anonymous").unwrap();
40//! // Do other secret stuff
41//! // Switch back to the insecure mode (if required)
42//! let mut ftp_stream = ftp_stream.into_insecure().unwrap();
43//! // Do all public stuff
44//! let _ = ftp_stream.quit();
45//! ```
46//!
47
48#[macro_use]
49extern crate lazy_static;
50extern crate chrono;
51extern crate regex;
52
53#[cfg(feature = "secure")]
54pub extern crate openssl;
55
56mod data_stream;
57mod ftp;
58pub mod status;
59pub mod types;
60
61pub use self::ftp::FtpStream;
62pub use self::types::FtpError;