pub struct FileEntryBuilder { /* private fields */ }Expand description
A builder for creating a regular file NormalEntry.
Data written via the Write trait is compressed and encrypted
according to the write options given at construction time.
§Examples
use libpna::FileEntryBuilder;
let mut builder = FileEntryBuilder::new("file.txt".into())?;
builder.write_all(b"content")?;
let entry = builder.build()?;Implementations§
Source§impl FileEntryBuilder
impl FileEntryBuilder
Sourcepub fn new(name: EntryName) -> Result<FileEntryBuilder, Error>
pub fn new(name: EntryName) -> Result<FileEntryBuilder, Error>
Creates a builder that stores data without compression or encryption.
§Errors
Returns an error if initialization fails.
Sourcepub fn new_with_options(
name: EntryName,
option: impl WriteOption,
) -> Result<FileEntryBuilder, Error>
pub fn new_with_options( name: EntryName, option: impl WriteOption, ) -> Result<FileEntryBuilder, Error>
Sourcepub fn metadata(&mut self, metadata: Metadata) -> &mut FileEntryBuilder ⓘ
pub fn metadata(&mut self, metadata: Metadata) -> &mut FileEntryBuilder ⓘ
Sets the metadata of the entry, replacing any previously set metadata.
The raw file size and compressed size recorded in the given metadata
are ignored; build() computes them from the written
data.
Sourcepub fn add_extra_chunk<T>(&mut self, chunk: T) -> &mut FileEntryBuilder ⓘ
pub fn add_extra_chunk<T>(&mut self, chunk: T) -> &mut FileEntryBuilder ⓘ
Adds extra chunk to the entry.
Sourcepub fn max_chunk_size(&mut self, size: NonZero<u32>) -> &mut FileEntryBuilder ⓘ
pub fn max_chunk_size(&mut self, size: NonZero<u32>) -> &mut FileEntryBuilder ⓘ
Sets the maximum chunk size for data written to this entry.
The default is the maximum allowed chunk size (~4GB).
Sourcepub fn store_file_size(&mut self, store: bool) -> &mut FileEntryBuilder ⓘ
pub fn store_file_size(&mut self, store: bool) -> &mut FileEntryBuilder ⓘ
Sets whether to store the raw file size in the entry metadata.
When true (the default), the raw file size is recorded; when
false, it is omitted.
Sourcepub fn build(self) -> Result<NormalEntry, Error>
pub fn build(self) -> Result<NormalEntry, Error>
Consumes this builder and returns the constructed NormalEntry.
§Errors
Returns an error if an I/O error occurs while building entry into buffer.
Trait Implementations§
Source§impl Write for FileEntryBuilder
impl Write for FileEntryBuilder
Source§fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Source§fn flush(&mut self) -> Result<(), Error>
fn flush(&mut self) -> Result<(), Error>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)Auto Trait Implementations§
impl !Freeze for FileEntryBuilder
impl !UnwindSafe for FileEntryBuilder
impl RefUnwindSafe for FileEntryBuilder
impl Send for FileEntryBuilder
impl Sync for FileEntryBuilder
impl Unpin for FileEntryBuilder
impl UnsafeUnpin for FileEntryBuilder
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more