Trait FtpEntryInfo

Source
pub trait FtpEntryInfo {
    // Required methods
    fn kind(&self) -> FtpEntryKind;
    fn name(&self) -> &str;
    fn size(&self) -> usize;
    fn date_str(&self) -> &str;

    // Provided method
    fn new(string: &str) -> Option<Self>
       where for<'a> Self: TryFrom<&'a str> { ... }
}
Expand description

All fields that supports both servers: Unix & MSDOS

Required Methods§

Source

fn kind(&self) -> FtpEntryKind

Represents type of the entry: directory, file, symlink or other.

Source

fn name(&self) -> &str

Returns name of the entry.

Source

fn size(&self) -> usize

Returns size of the entry.

Source

fn date_str(&self) -> &str

Returns date of the entry.

Provided Methods§

Source

fn new(string: &str) -> Option<Self>
where for<'a> Self: TryFrom<&'a str>,

Returns a new FtpEntry by given string if parsing was successful. Also you can create new FtpEntry by use TryFrom trait.

let ftp_response = "drwxr-xr-x  10 root   root    4096 Dec 21  2012 usr";

match FtpEntry::new(ftp_response) {
    Some(ftp_entry) => {
        assert_eq!(ftp_entry.name(), "usr");
        assert_eq!(ftp_entry.size(), 4096);
        assert_eq!(ftp_entry.date_str(), "Dec 21 2012");
    }
    None => println!("ftp_response is not valid ftp-entry!")
}

Implementors§