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§
Unix(FtpEntryUnix)
Msdos(FtpEntryMsdos)
Implementations§
Source§impl FtpEntry
impl FtpEntry
Sourcepub fn new(string: &str) -> Option<Self>
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!")
}
Sourcepub fn is_unix_type(&self) -> bool
pub fn is_unix_type(&self) -> bool
Returns true if FtpEntry
has UNIX-like entry, otherwise false.
Sourcepub fn is_msdos_type(&self) -> bool
pub fn is_msdos_type(&self) -> bool
Returns true if FtpEntry
has MSDOS-like entry, otherwise false.
Sourcepub fn to_unix_type(self) -> FtpEntryUnix
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.
Sourcepub fn to_msdos_type(self) -> FtpEntryMsdos
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.
Sourcepub fn try_to_unix_type(self) -> Result<FtpEntryUnix, Self>
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.
Sourcepub fn try_to_msdos_type(self) -> Result<FtpEntryMsdos, Self>
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.