Struct zip::write::FileOptions
source · pub struct FileOptions<'k, T: FileOptionExtension> { /* private fields */ }
Expand description
Metadata for a file to be written
Implementations§
source§impl<'k, T: FileOptionExtension> FileOptions<'k, T>
impl<'k, T: FileOptionExtension> FileOptions<'k, T>
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::Zlib
is the default. If all else fails,
CompressionMethod::Stored
becomes the default and files are written uncompressed.
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
None
is 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 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 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<'k> FileOptions<'k, ExtendedFileOptions>
impl<'k> FileOptions<'k, ExtendedFileOptions>
sourcepub fn add_extra_data(
&mut self,
header_id: u16,
data: &[u8],
central_only: bool
) -> ZipResult<()>
pub fn add_extra_data( &mut self, header_id: u16, data: &[u8], central_only: bool ) -> ZipResult<()>
Adds an extra data field.
sourcepub fn clear_extra_data(self) -> Self
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>
impl<'k, T: Clone + FileOptionExtension> Clone for FileOptions<'k, T>
source§fn clone(&self) -> FileOptions<'k, T>
fn clone(&self) -> FileOptions<'k, T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more