Struct FileOptions
#[non_exhaustive]
pub struct FileOptions<'k, 'n, T: FileOptionExtension> { /* private fields */ }
Metadata for a file to be written
Implementations
impl FileOptions<'_, '_, ExtendedFileOptions>
fn with_file_comment<S: Into<Box<str>>>(self, comment: S) -> SelfSet the file comment.
fn add_extra_data<D: AsRef<[u8]>>(&mut self, header_id: u16, data: D, central_only: bool) -> ZipResult<()>Adds an extra data field.
fn add_extra_field<D: AsRef<[u8]>>(&mut self, header_id: u16, data: D, central_only: bool) -> ZipResult<()>Adds an extra field.
fn clear_extra_data(self) -> SelfRemoves the extra fields.
fn clear_extra_fields(self) -> SelfRemoves the extra fields.
impl FileOptions<'static, 'static, ()>
const DEFAULT: Self = _;Constructs a const
FileOptionsobject.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
- The
impl<'k, 'n> FileOptions<'k, 'n, ()>
fn into_full_options(self) -> FullFileOptions<'k, 'n>Convert to
FullFileOptions.
impl<'k, 'n, T: FileOptionExtension> FileOptions<'k, 'n, T>
const fn has_encryption(&self) -> boolIndicates whether this file will be encrypted (whether with AES or
ZipCrypto).const fn compression_method(self, method: CompressionMethod) -> SelfSet the compression method for the new file
The default is
CompressionMethod::Deflatedif it is enabled. If not,CompressionMethod::Bzip2is the default if it is enabled. If neitherbzip2nordeflateis enabled,CompressionMethod::Storedbecomes the default and files are written uncompressed.const fn system(self, system: System) -> SelfSet the
systemfield for the new fileIf not set, the
zipcrate will use the current systemconst fn compression_level(self, level: Option<i64>) -> SelfSet the compression level for the new file
Nonevalue 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
const fn last_modified_time(self, mod_time: DateTime) -> SelfSet the last modified time
The default is the current timestamp if the 'time' feature is enabled, and 1980-01-01 otherwise
const fn unix_permissions(self, mode: u32) -> SelfSet the permissions for the new file.
The format is represented with unix-style permissions. The default is
0o644, which representsrw-r--r--for files, and0o755, which representsrwxr-xr-xfor 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.const fn external_attributes(self, external_perms: u32) -> SelfSet the external attributes for the file.
If you use both
Self::unix_permissionsandSelf::external_attributes, only external attributes are going to be usedconst fn large_file(self, large: bool) -> SelfSet whether the new file's compressed and uncompressed size is less than 4 GiB.
If set to
falseand the file exceeds the limit, an I/O error is thrown and the file is aborted. If set totrue, readers will require ZIP64 support and if the file does not exceed the limit, 20 B are wasted. The default isfalse.fn with_aes_encryption_and_salt(self, password: &'k [u8], salt: AesSalt) -> FileOptions<'k, 'n, T>Set the AES encryption parameters. The
saltmust be at least 8 bytes long for AES-128, and at least 16 bytes long for AES-256. This method is not recommended, since having a fixed salt is not secure. Consider usingwith_aes_encryptioninstead, which uses a random salt and is more secure.fn with_aes_encryption(self, mode: AesMode, password: &'k str) -> FileOptions<'k, 'n, T>Set the AES encryption parameters.
fn with_aes_encryption_bytes(self, mode: AesMode, password: &'k [u8]) -> FileOptions<'k, 'n, T>Set the AES encryption parameters.
const fn with_zopfli_buffer(self, size: Option<usize>) -> SelfSets 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
Noneindicates no buffer, which is recommended only when all non-empty writes are larger than about 32 KiB.const fn get_compression_level(&self) -> Option<i64>Returns the compression level currently set.
const fn with_alignment(self, alignment: u16) -> SelfSets the alignment to the given number of bytes.
Trait Implementations
impl<'k, 'n, T: Clone + FileOptionExtension> Clone for FileOptions<'k, 'n, T>
fn clone(&self) -> Self
impl<'k, 'n, T: Copy + FileOptionExtension> Copy for FileOptions<'k, 'n, T>
impl<'k, 'n, T: Debug + FileOptionExtension> Debug for FileOptions<'k, 'n, T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<'k, 'n, T: Eq + FileOptionExtension> Eq for FileOptions<'k, 'n, T>
impl<'k, 'n, T: FileOptionExtension> FileOptionsExt<'k> for FileOptions<'k, 'n, T>
fn with_deprecated_encryption(self, password: &'k [u8]) -> ZipResult<FileOptions<'k, 'n, T>>
impl<'k, 'n, T: PartialEq + FileOptionExtension> PartialEq for FileOptions<'k, 'n, T>
fn eq(&self, other: &Self) -> bool
impl<'k, 'n, T: PartialEq + FileOptionExtension> StructuralPartialEq for FileOptions<'k, 'n, T>
impl<T: FileOptionExtension> Default for FileOptions<'_, '_, T>
fn default() -> SelfConstruct a new
FileOptionsobject