Struct zip::tokio::read::ZipArchive

source ·
pub struct ZipArchive<S> { /* private fields */ }

Implementations§

source§

impl<S: AsyncRead + AsyncSeek> ZipArchive<S>

source

pub async fn new(reader: Pin<Box<S>>) -> ZipResult<ZipArchive<S>>

source§

impl<S: AsyncRead + AsyncSeek> ZipArchive<S>

source

pub async fn by_name( self: Pin<&mut Self>, name: &str ) -> ZipResult<Pin<Box<ZipFile<'_, S, ZipFileWrappedReader<Limiter<S>>>>>>

source

pub async fn by_index( self: Pin<&mut Self>, index: usize ) -> ZipResult<Pin<Box<ZipFile<'_, S, ZipFileWrappedReader<Limiter<S>>>>>>

source

pub async fn by_index_raw( self: Pin<&mut Self>, index: usize ) -> ZipResult<Pin<Box<ZipFile<'_, S, Limiter<S>>>>>

source

pub fn raw_entries_stream( self: Pin<&mut Self> ) -> impl Stream<Item = ZipResult<Pin<Box<ZipFile<'_, S, Limiter<S>>>>>> + '_

source

pub fn entries_stream( self: Pin<&mut Self> ) -> impl Stream<Item = ZipResult<Pin<Box<ZipFile<'_, S, ZipFileWrappedReader<Limiter<S>>>>>>> + '_

source

pub async fn extract_simple( self: Pin<&mut Self>, root: Arc<PathBuf> ) -> ZipResult<()>

 use std::{io::Cursor, pin::Pin, sync::Arc};
 use tokio::{io, fs};

 let buf = {
   use std::io::prelude::*;
   let buf = Cursor::new(Vec::new());
   let mut f = zip::ZipWriter::new(buf);
   let options = zip::write::FileOptions::default()
     .compression_method(zip::CompressionMethod::Deflated);
   f.start_file("a/b.txt", options)?;
   f.write_all(b"hello\n")?;
   f.finish()?
 };
 let mut f = zip::tokio::read::ZipArchive::new(Box::pin(buf)).await?;

 let t = tempfile::tempdir()?;

 let root = t.path();
 Pin::new(&mut f).extract_simple(Arc::new(root.to_path_buf())).await?;
 let msg = fs::read_to_string(root.join("a/b.txt")).await?;
 assert_eq!(&msg, "hello\n");
source

pub async fn extract(self: Pin<&mut Self>, root: Arc<PathBuf>) -> ZipResult<()>

 use std::{io::Cursor, pin::Pin, sync::Arc};
 use tokio::{io, fs};

 let buf = {
   use std::io::prelude::*;
   let buf = Cursor::new(Vec::new());
   let mut f = zip::ZipWriter::new(buf);
   let options = zip::write::FileOptions::default()
     .compression_method(zip::CompressionMethod::Deflated);
   f.start_file("a/b.txt", options)?;
   f.write_all(b"hello\n")?;
   f.finish()?
 };
 let mut f = zip::tokio::read::ZipArchive::new(Box::pin(buf)).await?;

 let t = tempfile::tempdir()?;

 let root = t.path();
 Pin::new(&mut f).extract(Arc::new(root.to_path_buf())).await?;
 let msg = fs::read_to_string(root.join("a/b.txt")).await?;
 assert_eq!(&msg, "hello\n");

Trait Implementations§

source§

impl<S: Debug> Debug for ZipArchive<S>

source§

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

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

impl<S> WrappedPin<S> for ZipArchive<S>

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for ZipArchive<S>where S: RefUnwindSafe,

§

impl<S> Send for ZipArchive<S>where S: Send,

§

impl<S> Sync for ZipArchive<S>where S: Sync,

§

impl<S> Unpin for ZipArchive<S>

§

impl<S> UnwindSafe for ZipArchive<S>where S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.