flep

Crates.ioflep
lib.rsflep
version0.2.0
sourcesrc
created_at2016-10-29 05:36:46.233359
updated_at2017-07-22 11:37:37.496892
descriptionFile transfer protocol (FTP) library
homepage
repositoryhttps://github.com/dylanmckay/flep
max_upload_size
id7033
size54,947
Dylan McKay (dylanmckay)

documentation

https://docs.rs/flep

README

flep

Crates.io Build Status license

An FTP server library.

Documentation

Example

Run ftp 127.0.0.1 2222 to connect to the server.

pub struct Server
{
    file_system: flep::fs::Memory,
}

impl flep::server::Server for Server
{
    fn welcome_message(&self) -> String { "Hello there!".to_string() }

    fn file_system(&self) -> &flep::fs::FileSystem {
        &self.file_system
    }

    fn file_system_mut(&mut self) -> &mut flep::fs::FileSystem {
        &mut self.file_system
    }
}

fn main() {
    flep::util::log::initialize_default().expect("could not setup logging");

    // Set up an in-memory file system.
    let mut file_system = flep::fs::Memory::new();
    file_system.write_file(&Path::new("README.txt"),
                           "hello there\nit is me".as_bytes().to_owned()).unwrap();

    // Start on port 2222
    let mut server = Server { file_system: file_system };
    flep::server::run(&mut server, "127.0.0.1:2222")
        .expect("error whilst running server");
}
Commit count: 135

cargo fmt