ftp 0.0.1

FTP client for Rust
docs.rs failed to build ftp-0.0.1
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

This client isn't really finished yet. It still requires a lot of work.

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::slice::bytes::MutableByteVector;
use ftp::FTPStream;

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

    match ftp_stream.login("anonymous", "somedude@yahoo.com") {
    	Ok(_) => (),
    	Err(e) => panic!("{}", e)
    }

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

    let mut data_stream = match ftp_stream.retr("ftpext-charter.txt") {
        Ok(data_stream) => data_stream,
        Err(e) => panic!("{}", e)
    };

    let mut buf = [0, ..100];
    let mut still_reading = true;
    while still_reading {
        buf.set_memory(0);
        match data_stream.read(&mut buf) {
            Ok(nread) => {
                if nread == 0 {
                    still_reading = false;
                } else {
                    match str::from_utf8(&buf) {
                        Some(s) => print!("{}", s),
                        None => panic!("Failure")
                    };
                }
            }
            Err(_) => still_reading = false,
        }
    }

    drop(data_stream);

    let _ = ftp_stream.quit();
}

License

MIT