ftp 0.0.3

FTP client for Rust
docs.rs failed to build ftp-0.0.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: ftp-3.0.1

rust-ftp

FTP client for Rust

Build Status

Installation

Add ftp via your Cargo.toml

[dependencies.ftp]
git = "https://github.com/mattnenterprise/rust-ftp"

Usage

extern crate ftp;

use std::str;
use std::io::{MemReader};
use ftp::FTPStream;

fn main() {
    let mut ftp_stream = match FTPStream::connect("127.0.0.1", 21) {
        Ok(s) => s,
        Err(e) => panic!("{}", e)
    };

    match ftp_stream.login("username", "password") {
        Ok(_) => (),
        Err(e) => panic!("{}", e)
    }

    match ftp_stream.current_dir() {
        Ok(dir) => println!("{}", dir),
        Err(e) => panic!("{}", e)
    }

    match ftp_stream.change_dir("test_data") {
        Ok(_) => (),
        Err(e) => panic!("{}", e)
    }

    //An easy way to retreive a file
    let remote_file = match ftp_stream.simple_retr("ftpext-charter.txt") {
        Ok(file) => file,
        Err(e) => panic!("{}", e)
    };

    match str::from_utf8(remote_file.into_inner().as_slice()) {
        Ok(s) => print!("{}", s),
        Err(e) => panic!("Error reading file data: {}", e)
    };

    //Store a file
    let file_data = format!("Some awesome file data man!!");
    let reader = &mut MemReader::new(file_data.into_bytes());
    match ftp_stream.stor("my_random_file.txt", reader) {
        Ok(_) => (),
        Err(e) => panic!("{}", e)
    }

    let _ = ftp_stream.quit();
}

License

MIT