Skip to main content

EntryOptions

Struct EntryOptions 

Source
pub struct EntryOptions {
    pub mtime: SystemTime,
    pub permissions: Option<u32>,
    pub uid_gid: Option<(u32, u32)>,
    pub comment: Option<String>,
}
Expand description

Per-entry options for appending to a ZIP archive.

Passed to ZipWriter::append_file, ZipWriter::append_directory, and ZipWriter::append_symlink to control metadata such as modification time, Unix permissions, UID/GID, and file comment.

Use the convenience constructors for common cases:

For full control, construct the struct directly:

use async_deflate_zip::EntryOptions;
use std::time::SystemTime;

let opts = EntryOptions {
    mtime: SystemTime::UNIX_EPOCH,
    permissions: Some(0o755),
    uid_gid: Some((1000, 1000)),
    comment: Some("my file".to_string()),
};

Fields§

§mtime: SystemTime

Last modification time. Stored in MS-DOS format in the fixed CD fields and as a Unix timestamp in the extended timestamp extra field (0x5455).

§permissions: Option<u32>

Unix permission bits (e.g. 0o644, 0o755). The file type bit (S_IFREG/S_IFDIR/S_IFLNK) is added automatically by the writer. When None, no Unix permissions are written.

§uid_gid: Option<(u32, u32)>

Unix user and group IDs. Stored in the 0x7875 (Ux) extra field.

§comment: Option<String>

Per-entry comment stored in the Central Directory. Maximum length is 65535 bytes. Comments longer than this will cause finalize to return ZipError::FieldTooLong.

Implementations§

Source§

impl EntryOptions

Source

pub async fn from_path<T: AsRef<Path>>(path: T) -> Result<Self>

Read metadata (mtime, permissions, uid/gid) from a real filesystem path.

The file’s content is not read — only symlink_metadata is queried so this works on symlinks, directories, and regular files alike.

On Unix, permission bits are extracted from the file’s mode and UID/GID from the file’s owner. On non-Unix platforms, permissions default to None and UID/GID to None.

Source

pub fn file() -> Self

Convenience options for a regular file: permissions 0o644, modification time set to now.

Source

pub fn directory() -> Self

Convenience options for a directory: permissions 0o755, modification time set to now.

Convenience options for a symbolic link: permissions 0o777, modification time set to now.

Trait Implementations§

Source§

impl Default for EntryOptions

Source§

fn default() -> Self

Returns the “default value” for a type. 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.