Module suppaftp::list

source ·
Expand description

§List

This module exposes the parser for the LIST command. Please note that there’s no guarantee this parser works and the reason is quite simple. There’s no specification regarding the LIST command output, so it basically depends on the implementation of the remote FTP server. Despite this though, this parser, has worked on all the ftp server I’ve used. If you find a variant which doesn’t work with this parser, please feel free to report an issue to https://github.com/veeso/suppaftp.

§Get started

Whenever you receive the output for your LIST command, all you have to do is to iterate over lines and call File::from_line() function as shown in the example.

use std::convert::TryFrom;
use suppaftp::{FtpStream, list::File};

// Connect to the server
let mut ftp_stream = FtpStream::connect("127.0.0.1:10021").unwrap_or_else(|err|
    panic!("{}", err)
);

// Authenticate
assert!(ftp_stream.login("test", "test").is_ok());

// List current directory
let files: Vec<File> = ftp_stream.list(None).ok().unwrap().iter().map(|x| File::try_from(x.as_str()).ok().unwrap()).collect();

// Disconnect from server
assert!(ftp_stream.quit().is_ok());
Run

Structs§

  • Describes a file entry on the remote system. This data type is returned in a collection after parsing a LIST output

Enums§