Metadata

Struct Metadata 

Source
pub struct Metadata {
    pub data_offset: u64,
    pub compressed_size: u64,
    pub uncompressed_size: u64,
    pub compression_method: CompressionMethod,
    pub crc32: u32,
    pub file_type: FileType,
    pub modification_time: Option<Timestamp>,
    pub access_time: Option<Timestamp>,
    pub creation_time: Option<Timestamp>,
    pub encryption: Option<EncryptionMethod>,
    /* private fields */
}
Expand description

The metadata of a ZIP entry.

Fields§

§data_offset: u64§compressed_size: u64§uncompressed_size: u64§compression_method: CompressionMethod§crc32: u32§file_type: FileType§modification_time: Option<Timestamp>§access_time: Option<Timestamp>§creation_time: Option<Timestamp>§encryption: Option<EncryptionMethod>

Implementations§

Source§

impl Metadata

Source

pub fn is_encrypted(&self) -> bool

Returns true if this file is encrypted.

Source

pub fn name(&self) -> &str

Gets the name of this entry.

Source

pub fn comment(&self) -> &str

Gets the comment of this entry.

Source

pub fn read<R: BufRead + Seek>(&self, reader: R) -> Result<impl Read + use<R>>

Returns a reader with the content of the file.

Unsupported compression methods and encrypted files will return an error.

Source

pub fn read_stored<R: Read + Seek>(&self, reader: R) -> Result<Take<R>>

Returns a reader with the content of the file.

Errors if the file is compressed, encrypted or corrupted. Is is not necessary to use Metadata::content_checker on the result.

It is useful if you know that the file is stored as-is and you want to take advantage of the BufReader or the Seek implementation.

Source

pub fn read_raw<R: Read + Seek>(&self, reader: R) -> Result<Take<R>>

Returns a reader with the raw, uncompressed, content of the file.

The uncompressed content should be checked with content_checker.

Source

pub fn content_checker<R: Read>(&self, reader: R) -> impl Read + use<R>

Wraps a reader to check that its content matches this metadata.

It is particularly useful in combinaison of read_raw.

Source

pub fn extract<R: BufRead + Seek>( &self, reader: &mut R, root: impl AsRef<Path>, ) -> Result<()>

Extracts this entry as if the root of the archive was at root.

Trait Implementations§

Source§

impl Debug for Metadata

Source§

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

Formats the value using the given formatter. Read more

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