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>
impl<'a> FilePayload<'a>
Sourcepub fn new<R>(size: u64, source: R) -> FilePayload<'a>where
R: AsyncRead + 'a,
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.
Sourcepub fn size(&self) -> u64
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.
Sourcepub async fn next_chunk<E>(&mut self) -> Result<Option<&[u8]>, BuildError<E>>
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>
impl FilePayload<'static>
Sourcepub async fn from_path<P>(path: P) -> Result<FilePayload<'static>, Error>
pub async fn from_path<P>(path: P) -> Result<FilePayload<'static>, Error>
Opens path and creates a payload from the complete regular file.
Sourcepub async fn from_file(file: File) -> Result<FilePayload<'static>, Error>
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.