Struct FileOptions

Source
pub struct FileOptions<'k, T: FileOptionExtension> { /* private fields */ }
Expand description

Metadata for a file to be written

Implementations§

Source§

impl<T: FileOptionExtension> FileOptions<'_, T>

Source

pub const fn compression_method(self, method: CompressionMethod) -> Self

Set the compression method for the new file

The default is CompressionMethod::Deflated if it is enabled. If not, CompressionMethod::Bzip2 is the default if it is enabled. If neither bzip2 nor deflate is enabled, CompressionMethod::Zlib is the default. If all else fails, CompressionMethod::Stored becomes the default and files are written uncompressed.

Source

pub const fn compression_level(self, level: Option<i64>) -> Self

Set the compression level for the new file

None value specifies default compression level.

Range of values depends on compression method:

  • Deflated: 10 - 264 for Zopfli, 0 - 9 for other encoders. Default is 24 if Zopfli is the only encoder, or 6 otherwise.
  • Bzip2: 0 - 9. Default is 6
  • Zstd: -7 - 22, with zero being mapped to default level. Default is 3
  • others: only None is allowed
Source

pub const fn last_modified_time(self, mod_time: DateTime) -> Self

Set the last modified time

The default is the current timestamp if the ‘time’ feature is enabled, and 1980-01-01 otherwise

Source

pub const fn unix_permissions(self, mode: u32) -> Self

Set the permissions for the new file.

The format is represented with unix-style permissions. The default is 0o644, which represents rw-r--r-- for files, and 0o755, which represents rwxr-xr-x for directories.

This method only preserves the file permissions bits (via a & 0o777) and discards higher file mode bits. So it cannot be used to denote an entry as a directory, symlink, or other special file type.

Source

pub const fn large_file(self, large: bool) -> Self

Set whether the new file’s compressed and uncompressed size is less than 4 GiB.

If set to false and the file exceeds the limit, an I/O error is thrown and the file is aborted. If set to true, readers will require ZIP64 support and if the file does not exceed the limit, 20 B are wasted. The default is false.

Source

pub const fn get_compression_level(&self) -> Option<i64>

Returns the compression level currently set.

Source

pub const fn with_alignment(self, alignment: u16) -> Self

Sets the alignment to the given number of bytes.

Source§

impl FileOptions<'_, ExtendedFileOptions>

Source

pub fn add_extra_data( &mut self, header_id: u16, data: Box<[u8]>, central_only: bool, ) -> ZipResult<()>

Adds an extra data field.

Source

pub fn clear_extra_data(self) -> Self

Removes the extra data fields.

Trait Implementations§

Source§

impl<'k, T: Clone + FileOptionExtension> Clone for FileOptions<'k, T>

Source§

fn clone(&self) -> FileOptions<'k, T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'k, T: Debug + FileOptionExtension> Debug for FileOptions<'k, T>

Source§

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

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

impl<T: FileOptionExtension> Default for FileOptions<'_, T>

Source§

fn default() -> Self

Construct a new FileOptions object

Source§

impl<T: FileOptionExtension> FileOptionsExt for FileOptions<'_, T>

Source§

fn with_deprecated_encryption(self, password: &[u8]) -> FileOptions<'static, T>

Write the file with the given password using the deprecated ZipCrypto algorithm. Read more
Source§

impl<'k, T: PartialEq + FileOptionExtension> PartialEq for FileOptions<'k, T>

Source§

fn eq(&self, other: &FileOptions<'k, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'k, T: Copy + FileOptionExtension> Copy for FileOptions<'k, T>

Source§

impl<'k, T: Eq + FileOptionExtension> Eq for FileOptions<'k, T>

Source§

impl<'k, T: FileOptionExtension> StructuralPartialEq for FileOptions<'k, T>

Auto Trait Implementations§

§

impl<'k, T> Freeze for FileOptions<'k, T>
where T: Freeze,

§

impl<'k, T> RefUnwindSafe for FileOptions<'k, T>
where T: RefUnwindSafe,

§

impl<'k, T> Send for FileOptions<'k, T>
where T: Send,

§

impl<'k, T> Sync for FileOptions<'k, T>
where T: Sync,

§

impl<'k, T> Unpin for FileOptions<'k, T>
where T: Unpin,

§

impl<'k, T> UnwindSafe for FileOptions<'k, T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.