Enum FtpEntry

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

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§

Source§

impl FtpEntry

Source

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

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

pub fn is_unix_type(&self) -> bool

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

Source

pub fn is_msdos_type(&self) -> bool

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

Source

pub fn to_unix_type(self) -> FtpEntryUnix

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.

Source

pub fn to_msdos_type(self) -> FtpEntryMsdos

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.

Source

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

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

Source

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

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

Trait Implementations§

Source§

impl Debug for FtpEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TryFrom<&str> for FtpEntry

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Deref for FtpEntry

Source§

type Target = dyn FtpEntryInfo

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.