Writer

Struct Writer 

Source
pub struct Writer<F: AsyncRead + Unpin> { /* private fields */ }
Expand description

Asar archive writer.

Implementations§

Source§

impl<F: AsyncRead + Unpin> Writer<F>

Source

pub fn new() -> Self

Creates a new, empty archive writer.

Source

pub fn add(&mut self, path: &str, content: F, size: u64)

Add an entry to the archive.

The entry’s parent directories are created recursively if they do not exist.

size should correspond with content. If size is smaller, exactly size bytes will be written. If size is bigger, the Writer::write method will fail. For convenience, you may want to use add_sized.

§Panic

The method panics if normalised path contains no filename, or if the path is already occupied by a previously inserted file.

Source

pub fn add_empty_folder(&mut self, path: &str)

Adds an empty folder recursively to the archive.

Source

pub async fn write(self, dest: &mut (impl AsyncWrite + Unpin)) -> Result<()>

Finishes the archive and writes the content into dest.

Source

pub fn into_stream(self) -> Result<impl Stream<Item = Result<Bytes>>>

Available on crate feature stream only.
Source§

impl<F: AsyncRead + AsyncSeek + Unpin> Writer<F>

Source

pub async fn add_sized(&mut self, path: &str, content: F) -> Result<()>

Add an entry to the archive.

Similar to Writer::add, but it uses AsyncSeekExt::seek to determine the size of the content.

For more information see Writer::add.

Source

pub async fn add_sized_with_integrity( &mut self, path: &str, content: F, ) -> Result<()>

Available on crate feature integrity only.

Trait Implementations§

Source§

impl<F: Debug + AsyncRead + Unpin> Debug for Writer<F>

Source§

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

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

impl<F: AsyncRead + Unpin> Default for Writer<F>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<F> Freeze for Writer<F>

§

impl<F> RefUnwindSafe for Writer<F>
where F: RefUnwindSafe,

§

impl<F> Send for Writer<F>
where F: Send,

§

impl<F> Sync for Writer<F>
where F: Sync,

§

impl<F> Unpin for Writer<F>

§

impl<F> UnwindSafe for Writer<F>
where F: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
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.