#[non_exhaustive]pub struct FileOptions<'k, 'n, T: FileOptionExtension> { /* private fields */ }Expand description
Metadata for a file to be written
Implementations§
Source§impl<'k, 'n, T: FileOptionExtension> FileOptions<'k, 'n, T>
impl<'k, 'n, T: FileOptionExtension> FileOptions<'k, 'n, T>
Sourcepub const fn has_encryption(&self) -> bool
pub const fn has_encryption(&self) -> bool
Indicates whether this file will be encrypted (whether with AES or ZipCrypto).
Sourcepub const fn compression_method(self, method: CompressionMethod) -> Self
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::Stored becomes the default and files are written uncompressed.
Sourcepub const fn system(self, system: System) -> Self
pub const fn system(self, system: System) -> Self
Set the system field for the new file
If not set, the zip crate will use the current system
Sourcepub const fn compression_level(self, level: Option<i64>) -> Self
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 6Zstd: -7 - 22, with zero being mapped to default level. Default is 3- others: only
Noneis allowed
Sourcepub const fn last_modified_time(self, mod_time: DateTime) -> Self
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
Sourcepub const fn unix_permissions(self, mode: u32) -> Self
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.
Sourcepub const fn external_attributes(self, external_perms: u32) -> Self
pub const fn external_attributes(self, external_perms: u32) -> Self
Set the external attributes for the file.
If you use both Self::unix_permissions and Self::external_attributes, only external
attributes are going to be used
Sourcepub const fn large_file(self, large: bool) -> Self
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.
Sourcepub const fn with_zopfli_buffer(self, size: Option<usize>) -> Self
pub const fn with_zopfli_buffer(self, size: Option<usize>) -> Self
Sets the size of the buffer used to hold the next block that Zopfli will compress. The
larger the buffer, the more effective the compression, but the more memory is required.
A value of None indicates no buffer, which is recommended only when all non-empty writes
are larger than about 32 KiB.
Sourcepub const fn get_compression_level(&self) -> Option<i64>
pub const fn get_compression_level(&self) -> Option<i64>
Returns the compression level currently set.
Sourcepub const fn with_alignment(self, alignment: u16) -> Self
pub const fn with_alignment(self, alignment: u16) -> Self
Sets the alignment to the given number of bytes.
Source§impl FileOptions<'_, '_, ExtendedFileOptions>
impl FileOptions<'_, '_, ExtendedFileOptions>
Sourcepub fn with_file_comment<S: Into<Box<str>>>(self, comment: S) -> Self
pub fn with_file_comment<S: Into<Box<str>>>(self, comment: S) -> Self
Set the file comment.
Sourcepub fn add_extra_data<D: AsRef<[u8]>>(
&mut self,
header_id: u16,
data: D,
central_only: bool,
) -> ZipResult<()>
👎Deprecated: use add_extra_field()
pub fn add_extra_data<D: AsRef<[u8]>>( &mut self, header_id: u16, data: D, central_only: bool, ) -> ZipResult<()>
use add_extra_field()
Adds an extra data field.
Sourcepub fn add_extra_field<D: AsRef<[u8]>>(
&mut self,
header_id: u16,
data: D,
central_only: bool,
) -> ZipResult<()>
pub fn add_extra_field<D: AsRef<[u8]>>( &mut self, header_id: u16, data: D, central_only: bool, ) -> ZipResult<()>
Adds an extra field.
Sourcepub fn clear_extra_data(self) -> Self
👎Deprecated: use clear_extra_fields
pub fn clear_extra_data(self) -> Self
use clear_extra_fields
Removes the extra fields.
Sourcepub fn clear_extra_fields(self) -> Self
pub fn clear_extra_fields(self) -> Self
Removes the extra fields.
Source§impl FileOptions<'static, 'static, ()>
impl FileOptions<'static, 'static, ()>
Sourcepub const DEFAULT: Self
pub const DEFAULT: Self
Constructs a const FileOptions object.
Note: This value is different than the return value of FileOptions::default():
- The
last_modified_timeisDateTime::DEFAULT. This corresponds to 1980-01-01 00:00:00
Source§impl<'k, 'n> FileOptions<'k, 'n, ()>
impl<'k, 'n> FileOptions<'k, 'n, ()>
Sourcepub fn into_full_options(self) -> FullFileOptions<'k, 'n>
pub fn into_full_options(self) -> FullFileOptions<'k, 'n>
Convert to FullFileOptions.
Trait Implementations§
Source§impl<'k, 'n, T: Clone + FileOptionExtension> Clone for FileOptions<'k, 'n, T>
impl<'k, 'n, T: Clone + FileOptionExtension> Clone for FileOptions<'k, 'n, T>
Source§fn clone(&self) -> FileOptions<'k, 'n, T>
fn clone(&self) -> FileOptions<'k, 'n, T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'k, 'n, T: Copy + FileOptionExtension> Copy for FileOptions<'k, 'n, T>
Source§impl<'k, 'n, T: Debug + FileOptionExtension> Debug for FileOptions<'k, 'n, T>
impl<'k, 'n, T: Debug + FileOptionExtension> Debug for FileOptions<'k, 'n, T>
Source§impl<T: FileOptionExtension> Default for FileOptions<'_, '_, T>
impl<T: FileOptionExtension> Default for FileOptions<'_, '_, T>
impl<'k, 'n, T: Eq + FileOptionExtension> Eq for FileOptions<'k, 'n, T>
Source§impl<'k, 'n, T: FileOptionExtension> FileOptionsExt<'k> for FileOptions<'k, 'n, T>
impl<'k, 'n, T: FileOptionExtension> FileOptionsExt<'k> for FileOptions<'k, 'n, T>
Source§fn with_deprecated_encryption(
self,
password: &'k [u8],
) -> ZipResult<FileOptions<'k, 'n, T>>
fn with_deprecated_encryption( self, password: &'k [u8], ) -> ZipResult<FileOptions<'k, 'n, T>>
ZipCrypto algorithm. Read moreSource§impl<'k, 'n, T: PartialEq + FileOptionExtension> PartialEq for FileOptions<'k, 'n, T>
impl<'k, 'n, T: PartialEq + FileOptionExtension> PartialEq for FileOptions<'k, 'n, T>
impl<'k, 'n, T: PartialEq + FileOptionExtension> StructuralPartialEq for FileOptions<'k, 'n, T>
Auto Trait Implementations§
impl<'k, 'n, T> Freeze for FileOptions<'k, 'n, T>where
T: Freeze,
impl<'k, 'n, T> RefUnwindSafe for FileOptions<'k, 'n, T>where
T: RefUnwindSafe,
impl<'k, 'n, T> Send for FileOptions<'k, 'n, T>where
T: Send,
impl<'k, 'n, T> Sync for FileOptions<'k, 'n, T>where
T: Sync,
impl<'k, 'n, T> Unpin for FileOptions<'k, 'n, T>where
T: Unpin,
impl<'k, 'n, T> UnsafeUnpin for FileOptions<'k, 'n, T>where
T: UnsafeUnpin,
impl<'k, 'n, T> UnwindSafe for FileOptions<'k, 'n, T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.