Skip to main content

FilePayload

Struct FilePayload 

Source
pub struct FilePayload<'a> { /* private fields */ }
Expand description

A format-neutral, uncompressed file payload supplied to an ArchiveBuilder implementation.

Implementations§

Source§

impl<'a> FilePayload<'a>

Source

pub fn new<R>(size: u64, source: R) -> FilePayload<'a>
where R: AsyncRead + 'a,

Creates a payload with a declared logical size and AsyncRead source.

The builder reads exactly size bytes from source. Additional bytes remain unread, while a source that ends early causes the addition to fail.

Source

pub fn size(&self) -> u64

Returns the logical, uncompressed source size in bytes.

This is the total number of bytes yielded by Self::next_chunk, not necessarily the size ultimately stored by the archive format.

Source

pub async fn next_chunk<E>(&mut self) -> Result<Option<&[u8]>, BuildError<E>>

Returns the next chunk of logical, uncompressed source bytes.

Once this method has been called, the payload cannot be passed to Builder::add_file.

Source§

impl FilePayload<'static>

Source

pub async fn from_path<P>(path: P) -> Result<FilePayload<'static>, Error>
where P: AsRef<Path>,

Opens path and creates a payload from the complete regular file.

Source

pub async fn from_file(file: File) -> Result<FilePayload<'static>, Error>

Creates a payload from the unread contents of a tokio::fs::File.

The declared size is the file length minus its current stream position. This constructor rejects filesystem objects that are not regular files.

Trait Implementations§

Source§

impl<'a> From<&'a [u8]> for FilePayload<'a>

Source§

fn from(bytes: &'a [u8]) -> FilePayload<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FilePayload<'a>

§

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

§

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

§

impl<'a> !UnwindSafe for FilePayload<'a>

§

impl<'a> Freeze for FilePayload<'a>

§

impl<'a> Unpin for FilePayload<'a>

§

impl<'a> UnsafeUnpin for FilePayload<'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.