Struct zip::tokio::read::ZipArchive
source · pub struct ZipArchive<S> { /* private fields */ }
Implementations§
source§impl<S: AsyncRead + AsyncSeek> ZipArchive<S>
impl<S: AsyncRead + AsyncSeek> ZipArchive<S>
source§impl<S: AsyncRead + AsyncSeek> ZipArchive<S>
impl<S: AsyncRead + AsyncSeek> ZipArchive<S>
pub async fn by_name( self: Pin<&mut Self>, name: &str ) -> ZipResult<Pin<Box<ZipFile<'_, S, ZipFileWrappedReader<Limiter<S>>>>>>
pub async fn by_index( self: Pin<&mut Self>, index: usize ) -> ZipResult<Pin<Box<ZipFile<'_, S, ZipFileWrappedReader<Limiter<S>>>>>>
pub async fn by_index_raw( self: Pin<&mut Self>, index: usize ) -> ZipResult<Pin<Box<ZipFile<'_, S, Limiter<S>>>>>
pub fn raw_entries_stream( self: Pin<&mut Self> ) -> impl Stream<Item = ZipResult<Pin<Box<ZipFile<'_, S, Limiter<S>>>>>> + '_
pub fn entries_stream( self: Pin<&mut Self> ) -> impl Stream<Item = ZipResult<Pin<Box<ZipFile<'_, S, ZipFileWrappedReader<Limiter<S>>>>>>> + '_
sourcepub async fn extract_simple(
self: Pin<&mut Self>,
root: Arc<PathBuf>
) -> ZipResult<()>
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");
sourcepub async fn extract(self: Pin<&mut Self>, root: Arc<PathBuf>) -> ZipResult<()>
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>
impl<S: Debug> Debug for ZipArchive<S>
source§impl<S> WrappedPin<S> for ZipArchive<S>
impl<S> WrappedPin<S> for ZipArchive<S>
fn unwrap_inner_pin(self) -> Pin<Box<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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more