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>
impl<W: InnerWriterTrait> ArchiveWriter<'_, W>
Sourcepub fn from_config(dest: W, config: ArchiveWriterConfig) -> Result<Self, Error>
pub fn from_config(dest: W, config: ArchiveWriterConfig) -> Result<Self, Error>
Create an ArchiveWriter from config.
Sourcepub fn new(
dest: W,
encryption_public_keys: &[MLAEncryptionPublicKey],
signing_private_keys: &[MLASigningPrivateKey],
) -> Result<Self, Error>
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.
Sourcepub fn finalize(self) -> Result<W, Error>
pub fn finalize(self) -> Result<W, Error>
Finalize an archive (appends footer, finalize compression, truncation protection, etc.).
Must be done to use ArchiveReader then.
Sourcepub fn start_entry(&mut self, name: EntryName) -> Result<ArchiveEntryId, Error>
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.
Sourcepub fn append_entry_content<U: Read>(
&mut self,
id: ArchiveEntryId,
size: u64,
src: U,
) -> Result<(), Error>
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.
Sourcepub fn end_entry(&mut self, id: ArchiveEntryId) -> Result<(), Error>
pub fn end_entry(&mut self, id: ArchiveEntryId) -> Result<(), Error>
Mark an entry as terminated and record its Sha256 hash.