[][src]Enum ftp_cmd_list_parse::FtpEntry

pub enum FtpEntry {
    Unix(FtpEntryUnix),
    Msdos(FtpEntryMsdos),
}

Represents parsed string as ftp entry.

Implements Deref to &dyn FtpEntryInfo, so you can get access to general fields that supports both servers: Unix & MSDOS.

Variants

Implementations

impl FtpEntry[src]

pub fn new(string: &str) -> Option<Self>[src]

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

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!")
}

pub fn is_unix_type(&self) -> bool[src]

Returns true if FtpEntry has UNIX-like entry, otherwise false.

pub fn is_msdos_type(&self) -> bool[src]

Returns true if FtpEntry has MSDOS-like entry, otherwise false.

pub fn to_unix_type(self) -> FtpEntryUnix[src]

Converts FtpEntry to FtpEntryUnix. Its may be useful if you need to get additional infomation like permissions, group, owner and others.

Panics

Panics if the value is not a Unix-like entry. If you not sure what kind of FtpEntry is, use try_to_unix_type instead.

pub fn to_msdos_type(self) -> FtpEntryMsdos[src]

Converts FtpEntry to FtpEntryMsdos.

Panics

Panics if the value is not a Msdos-like entry. If you not sure what kind of FtpEntry is, use try_to_msdos_type instead.

pub fn try_to_unix_type(self) -> Result<FtpEntryUnix, Self>[src]

Tries to convert FtpEntry to FtpEntryUnix. If it is impossible, returns FtpEntry back to caller.

pub fn try_to_msdos_type(self) -> Result<FtpEntryMsdos, Self>[src]

Tries to convert FtpEntry to FtpEntryMsdos. If it is impossible, returns FtpEntry back to caller.

Trait Implementations

impl Debug for FtpEntry[src]

impl Deref for FtpEntry[src]

type Target = dyn FtpEntryInfo

The resulting type after dereferencing.

impl TryFrom<&'_ str> for FtpEntry[src]

type Error = ()

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.