Skip to main content

ArchiveWriter

Struct ArchiveWriter 

Source
pub struct ArchiveWriter<'a, W: 'a + InnerWriterTrait> { /* private fields */ }
Expand description

Use this to write an archive

See crate root documentation for example usage.

Don’t forget to call ArchiveWriter::finalize

Implementations§

Source§

impl<W: InnerWriterTrait> ArchiveWriter<'_, W>

Source

pub fn from_config(dest: W, config: ArchiveWriterConfig) -> Result<Self, Error>

Create an ArchiveWriter from config.

Source

pub fn new( dest: W, encryption_public_keys: &[MLAEncryptionPublicKey], signing_private_keys: &[MLASigningPrivateKey], ) -> Result<Self, Error>

Create an ArchiveWriter with a default config (encryption, signature and compression with default level).

Do not mix up keys. If A sends an archive to B, encryption_public_keys must contain B’s encryption public key and signing_private_keys must contain A’s signature private key.

Returns ConfigError::EncryptionKeyIsMissing if encryption_public_keys is empty. Returns ConfigError::PrivateKeyNotSet if signing_private_keys is empty.

Source

pub fn finalize(self) -> Result<W, Error>

Finalize an archive (appends footer, finalize compression, truncation protection, etc.).

Must be done to use ArchiveReader then.

Source

pub fn start_entry(&mut self, name: EntryName) -> Result<ArchiveEntryId, Error>

Start a new entry in archive without giving content for the moment.

Returns an Id that must be kept to be able to append data to this entry.

See ArchiveWriter::append_entry_content and ArchiveWriter::end_entry.

Source

pub fn append_entry_content<U: Read>( &mut self, id: ArchiveEntryId, size: u64, src: U, ) -> Result<(), Error>

Appends data to an entry started with ArchiveWriter::start_entry.

Can be called multiple times to append data to the same entry. Can be interleaved with other calls writing data for other entries.

Source

pub fn end_entry(&mut self, id: ArchiveEntryId) -> Result<(), Error>

Mark an entry as terminated and record its Sha256 hash.

Source

pub fn add_entry<U: Read>( &mut self, name: EntryName, size: u64, src: U, ) -> Result<(), Error>

Helper calling start_entry, append_entry_content and end_entry one after the other.

Source

pub fn flush(&mut self) -> Result<()>

Flushes data to the destination Writer W. Calls flush on the destination too.

Auto Trait Implementations§

§

impl<'a, W> Freeze for ArchiveWriter<'a, W>

§

impl<'a, W> !RefUnwindSafe for ArchiveWriter<'a, W>

§

impl<'a, W> !Send for ArchiveWriter<'a, W>

§

impl<'a, W> !Sync for ArchiveWriter<'a, W>

§

impl<'a, W> Unpin for ArchiveWriter<'a, W>

§

impl<'a, W> UnsafeUnpin for ArchiveWriter<'a, W>

§

impl<'a, W> !UnwindSafe for ArchiveWriter<'a, W>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V