Struct tokio_tar::Archive

source ·
pub struct Archive<R: Read + Unpin> { /* private fields */ }
Expand description

A top-level representation of an archive file.

This archive can have an entry added to it and it can be iterated over.

Implementations§

source§

impl<R: Read + Unpin> Archive<R>

source

pub fn new(obj: R) -> Archive<R>

Create a new archive with the underlying object as the reader.

source

pub fn into_inner(self) -> Result<R, Self>

Unwrap this archive, returning the underlying object.

source

pub fn entries(&mut self) -> Result<Entries<R>>

Construct an stream over the entries in this archive.

Note that care must be taken to consider each entry within an archive in sequence. If entries are processed out of sequence (from what the stream returns), then the contents read for each entry may be corrupted.

source

pub fn entries_raw(&mut self) -> Result<RawEntries<R>>

Construct an stream over the raw entries in this archive.

Note that care must be taken to consider each entry within an archive in sequence. If entries are processed out of sequence (from what the stream returns), then the contents read for each entry may be corrupted.

source

pub async fn unpack<P: AsRef<Path>>(&mut self, dst: P) -> Result<()>

Unpacks the contents tarball into the specified dst.

This function will iterate over the entire contents of this tarball, extracting each file in turn to the location specified by the entry’s path name.

This operation is relatively sensitive in that it will not write files outside of the path specified by dst. Files in the archive which have a ‘..’ in their path are skipped during the unpacking process.

Examples
use tokio::fs::File;
use tokio_tar::Archive;

let mut ar = Archive::new(File::open("foo.tar").await?);
ar.unpack("foo").await?;

Trait Implementations§

source§

impl<R: Read + Unpin> AsyncRead for Archive<R>

source§

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, into: &mut ReadBuf<'_> ) -> Poll<Result<()>>

Attempts to read from the AsyncRead into buf. Read more
source§

impl<R: Read + Unpin> Clone for Archive<R>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Debug + Read + Unpin> Debug for Archive<R>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> !RefUnwindSafe for Archive<R>

§

impl<R> Send for Archive<R>where R: Send,

§

impl<R> Sync for Archive<R>where R: Send,

§

impl<R> Unpin for Archive<R>

§

impl<R> !UnwindSafe for Archive<R>

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<R> AsyncReadExt for Rwhere R: AsyncRead + ?Sized,

source§

fn chain<R>(self, next: R) -> Chain<Self, R>where Self: Sized, R: AsyncRead,

Creates a new AsyncRead instance that chains this stream with next. Read more
source§

fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where Self: Unpin,

Pulls some bytes from this source into the specified buffer, returning how many bytes were read. Read more
source§

fn read_buf<B, 'a>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>where Self: Sized + Unpin, B: BufMut,

Pulls some bytes from this source into the specified buffer, advancing the buffer’s internal cursor. Read more
source§

fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where Self: Unpin,

Reads the exact number of bytes required to fill buf. Read more
source§

fn read_u8<'a>(&'a mut self) -> ReadU8<&'a mut Self>where Self: Unpin,

Reads an unsigned 8 bit integer from the underlying reader. Read more
source§

fn read_i8<'a>(&'a mut self) -> ReadI8<&'a mut Self>where Self: Unpin,

Reads a signed 8 bit integer from the underlying reader. Read more
source§

fn read_u16<'a>(&'a mut self) -> ReadU16<&'a mut Self>where Self: Unpin,

Reads an unsigned 16-bit integer in big-endian order from the underlying reader. Read more
source§

fn read_i16<'a>(&'a mut self) -> ReadI16<&'a mut Self>where Self: Unpin,

Reads a signed 16-bit integer in big-endian order from the underlying reader. Read more
source§

fn read_u32<'a>(&'a mut self) -> ReadU32<&'a mut Self>where Self: Unpin,

Reads an unsigned 32-bit integer in big-endian order from the underlying reader. Read more
source§

fn read_i32<'a>(&'a mut self) -> ReadI32<&'a mut Self>where Self: Unpin,

Reads a signed 32-bit integer in big-endian order from the underlying reader. Read more
source§

fn read_u64<'a>(&'a mut self) -> ReadU64<&'a mut Self>where Self: Unpin,

Reads an unsigned 64-bit integer in big-endian order from the underlying reader. Read more
source§

fn read_i64<'a>(&'a mut self) -> ReadI64<&'a mut Self>where Self: Unpin,

Reads an signed 64-bit integer in big-endian order from the underlying reader. Read more
source§

fn read_u128<'a>(&'a mut self) -> ReadU128<&'a mut Self>where Self: Unpin,

Reads an unsigned 128-bit integer in big-endian order from the underlying reader. Read more
source§

fn read_i128<'a>(&'a mut self) -> ReadI128<&'a mut Self>where Self: Unpin,

Reads an signed 128-bit integer in big-endian order from the underlying reader. Read more
source§

fn read_f32<'a>(&'a mut self) -> ReadF32<&'a mut Self>where Self: Unpin,

Reads an 32-bit floating point type in big-endian order from the underlying reader. Read more
source§

fn read_f64<'a>(&'a mut self) -> ReadF64<&'a mut Self>where Self: Unpin,

Reads an 64-bit floating point type in big-endian order from the underlying reader. Read more
source§

fn read_u16_le<'a>(&'a mut self) -> ReadU16Le<&'a mut Self>where Self: Unpin,

Reads an unsigned 16-bit integer in little-endian order from the underlying reader. Read more
source§

fn read_i16_le<'a>(&'a mut self) -> ReadI16Le<&'a mut Self>where Self: Unpin,

Reads a signed 16-bit integer in little-endian order from the underlying reader. Read more
source§

fn read_u32_le<'a>(&'a mut self) -> ReadU32Le<&'a mut Self>where Self: Unpin,

Reads an unsigned 32-bit integer in little-endian order from the underlying reader. Read more
source§

fn read_i32_le<'a>(&'a mut self) -> ReadI32Le<&'a mut Self>where Self: Unpin,

Reads a signed 32-bit integer in little-endian order from the underlying reader. Read more
source§

fn read_u64_le<'a>(&'a mut self) -> ReadU64Le<&'a mut Self>where Self: Unpin,

Reads an unsigned 64-bit integer in little-endian order from the underlying reader. Read more
source§

fn read_i64_le<'a>(&'a mut self) -> ReadI64Le<&'a mut Self>where Self: Unpin,

Reads an signed 64-bit integer in little-endian order from the underlying reader. Read more
source§

fn read_u128_le<'a>(&'a mut self) -> ReadU128Le<&'a mut Self>where Self: Unpin,

Reads an unsigned 128-bit integer in little-endian order from the underlying reader. Read more
source§

fn read_i128_le<'a>(&'a mut self) -> ReadI128Le<&'a mut Self>where Self: Unpin,

Reads an signed 128-bit integer in little-endian order from the underlying reader. Read more
source§

fn read_f32_le<'a>(&'a mut self) -> ReadF32Le<&'a mut Self>where Self: Unpin,

Reads an 32-bit floating point type in little-endian order from the underlying reader. Read more
source§

fn read_f64_le<'a>(&'a mut self) -> ReadF64Le<&'a mut Self>where Self: Unpin,

Reads an 64-bit floating point type in little-endian order from the underlying reader. Read more
source§

fn read_to_end<'a>( &'a mut self, buf: &'a mut Vec<u8, Global> ) -> ReadToEnd<'a, Self>where Self: Unpin,

Reads all bytes until EOF in this source, placing them into buf. Read more
source§

fn read_to_string<'a>( &'a mut self, dst: &'a mut String ) -> ReadToString<'a, Self>where Self: Unpin,

Reads all bytes until EOF in this source, appending them to buf. Read more
source§

fn take(self, limit: u64) -> Take<Self>where Self: Sized,

Creates an adaptor which reads at most limit bytes from it. 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.