Entry

Enum Entry 

Source
pub enum Entry<'a> {
    File(FileEntry<'a>),
    Directory(DirEntry<'a>),
    Symlink(SymlinkEntry<'a>),
}
Expand description

An entry in the archive of any type.

This enum provides generic access to archive entries when the caller needs to handle any entry type. For type-specific access, use [ArchiveRead::file], [ArchiveRead::folder], or the entry’s conversion methods.

§Example

match archive.entry("some/path")? {
    Entry::File(f) => println!("file: {} bytes", f.size()),
    Entry::Directory(d) => println!("dir: {}", d.path()),
    Entry::Symlink(s) => println!("link -> {}", s.target().unwrap_or("<binary>")),
}

Variants§

§

File(FileEntry<'a>)

A regular file entry.

§

Directory(DirEntry<'a>)

A directory entry.

A symbolic link entry.

Implementations§

Source§

impl<'a> Entry<'a>

Source

pub fn is_file(&self) -> bool

Returns true if this is a file entry.

Source

pub fn is_directory(&self) -> bool

Returns true if this is a directory entry.

Returns true if this is a symlink entry.

Source

pub fn as_file(&self) -> Option<&FileEntry<'a>>

Returns the file entry if this is a file, or None otherwise.

Source

pub fn as_directory(&self) -> Option<&DirEntry<'a>>

Returns the directory entry if this is a directory, or None otherwise.

Returns the symlink entry if this is a symlink, or None otherwise.

Source

pub fn into_file(self) -> Option<FileEntry<'a>>

Converts into a file entry if this is a file, or None otherwise.

Source

pub fn into_directory(self) -> Option<DirEntry<'a>>

Converts into a directory entry if this is a directory, or None otherwise.

Converts into a symlink entry if this is a symlink, or None otherwise.

Trait Implementations§

Source§

impl<'a> Debug for Entry<'a>

Source§

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

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

impl<'a> From<DirEntry<'a>> for Entry<'a>

Source§

fn from(entry: DirEntry<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<FileEntry<'a>> for Entry<'a>

Source§

fn from(entry: FileEntry<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<SymlinkEntry<'a>> for Entry<'a>

Source§

fn from(entry: SymlinkEntry<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for Entry<'a>

§

impl<'a> RefUnwindSafe for Entry<'a>

§

impl<'a> Send for Entry<'a>

§

impl<'a> Sync for Entry<'a>

§

impl<'a> Unpin for Entry<'a>

§

impl<'a> UnwindSafe for Entry<'a>

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<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.