Archive

Struct Archive 

Source
pub struct Archive<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Archive<'a>

Source

pub fn open<F>(source: Source<'a>, flags: F) -> Result<Archive<'a>>
where F: AsRef<[OpenFlag]>,

Source

pub fn close(self) -> Result<(), (Self, Error)>

Closes and consumes a zip file. If this fails, the failed-to-close zipfile and an error will be returned.

Source

pub fn discard(self)

Discard and consume the zipfile. This will never fail.

Source

pub fn add<'b: 'a, N>( &mut self, name: N, source: Source<'b>, encoding: Encoding, compression: Compression, mode: Option<u16>, mtime: Option<u32>, overwrite: bool, ) -> Result<u64>
where N: AsRef<CStr>,

Add a file to the zip archive. Returns the index of the new file. The mtime parameter is given as a big-endian u32 DOS timestamp

Source

pub fn add_dir_entry<N>( &mut self, name: N, encoding: Encoding, mode: Option<u16>, mtime: Option<u32>, ) -> Result<u64>
where N: AsRef<CStr>,

Add a directory entry to the zip archive. Returns the index of the new entry. The mtime parameter is given as a big-endian u32 DOS timestamp The source must outlive the archive, because according to the libzip interface, changes are only written when the archive is closed, and the source may be used until then. If you need to work with a short-lived source, consider closing and re-opening the archive for each operation.

Source

pub fn replace<'b: 'a>(&mut self, index: u64, source: Source<'b>) -> Result<()>

Replace a file in the zip archive. The source must outlive the archive, because according to the libzip interface, changes are only written when the archive is closed, and the source may be used until then. If you need to work with a short-lived source, consider closing and re-opening the archive for each operation.

Source

pub fn open_file<N, O, L>( &mut self, name: N, open_flags: O, locate_flags: L, ) -> Result<File<'_>>
where N: AsRef<CStr>, O: AsRef<[FileOpenFlag]>, L: AsRef<[LocateFlag]>,

Add a file to the zip archive. Returns the index of the new file.

Trait Implementations§

Source§

impl<'a> Debug for Archive<'a>

Source§

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

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

impl Drop for Archive<'_>

Closes the archive, silently discarding on error. It’s strongly recommended to use the Archive::close method instead and validate that no errors have occurred.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Archive<'a>

§

impl<'a> RefUnwindSafe for Archive<'a>

§

impl<'a> !Send for Archive<'a>

§

impl<'a> !Sync for Archive<'a>

§

impl<'a> Unpin for Archive<'a>

§

impl<'a> UnwindSafe for Archive<'a>

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.