Crates.io | flep |
lib.rs | flep |
version | 0.2.0 |
source | src |
created_at | 2016-10-29 05:36:46.233359 |
updated_at | 2017-07-22 11:37:37.496892 |
description | File transfer protocol (FTP) library |
homepage | |
repository | https://github.com/dylanmckay/flep |
max_upload_size | |
id | 7033 |
size | 54,947 |
An FTP server library.
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");
}