Struct libpna::ArchiveWriter

source ·
pub struct ArchiveWriter<W: Write> { /* private fields */ }
Expand description

A writer for Portable-Network-Archive.

Implementations§

source§

impl<W: Write> ArchiveWriter<W>

source

pub fn write_header(write: W) -> Result<Self>

Writes the PNA archive header to the given Write object.

Arguments
  • write - The Write object to write the header to.
Examples
use std::fs::File;
use libpna::ArchiveWriter;

let file = File::create("example.pna").unwrap();
let mut archive_writer = ArchiveWriter::write_header(file).unwrap();
archive_writer.finalize().unwrap();
source

pub fn add_solid_entries(&mut self, entries: impl SolidEntries) -> Result<usize>

Adds solid entries to the current writer.

This function takes an entries that implement the SolidEntries trait. The entries are converted to bytes and written to the writer. The function returns the number of bytes written.

Arguments
  • entries: An entries that implement the SolidEntries trait.
Returns

The number of bytes written to the writer.

Errors

This function may return an io::Error if the writing operation fails.

Examples
use std::fs::File;
use libpna::{ArchiveWriter, SolidEntriesBuilder, WriteOptionBuilder};

let file = File::create("example.pna").unwrap();
let mut archive_writer = ArchiveWriter::write_header(file).unwrap();
let solid_builder = SolidEntriesBuilder::new(WriteOptionBuilder::new().build()).unwrap();
let entries = solid_builder.build().unwrap();
archive_writer.add_solid_entries(entries).unwrap();
archive_writer.finalize().unwrap();
source

pub fn add_entry(&mut self, entry: impl Entry) -> Result<usize>

Adds a new entry to the archive.

Arguments
  • entry - The entry to add to the archive.
Examples
use std::fs::File;
use libpna::{ArchiveWriter, EntryBuilder, WriteOptionBuilder};

let file = File::create("example.pna").unwrap();
let mut archive_writer = ArchiveWriter::write_header(file).unwrap();
archive_writer.add_entry(EntryBuilder::new_file("example.txt".into(), WriteOptionBuilder::new().build()).unwrap().build().unwrap()).unwrap();
archive_writer.finalize().unwrap();
source

pub fn add_entry_part(&mut self, entry_part: EntryPart) -> Result<usize>

Adds a part of an entry to the archive.

Arguments
  • entry_part - The part of an entry to add to the archive.
Examples
use std::fs::File;
use libpna::{ArchiveWriter, EntryPart, EntryBuilder, WriteOptionBuilder};

let part1_file = File::create("example.part1.pna").unwrap();
let mut part1_writer = ArchiveWriter::write_header(part1_file).unwrap();
let entry = EntryBuilder::new_file("example.txt".into(), WriteOptionBuilder::new().build()).unwrap().build().unwrap();
part1_writer.add_entry_part(EntryPart::from(entry)).unwrap();

let part2_file = File::create("example.part2.pna").unwrap();
let part2_writer = part1_writer.split_to_next_archive(part2_file).unwrap();
part2_writer.finalize().unwrap();
source

pub fn split_to_next_archive<OW: Write>( self, writer: OW ) -> Result<ArchiveWriter<OW>>

source

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

Auto Trait Implementations§

§

impl<W> RefUnwindSafe for ArchiveWriter<W>where W: RefUnwindSafe,

§

impl<W> Send for ArchiveWriter<W>where W: Send,

§

impl<W> Sync for ArchiveWriter<W>where W: Sync,

§

impl<W> Unpin for ArchiveWriter<W>where W: Unpin,

§

impl<W> UnwindSafe for ArchiveWriter<W>where W: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

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

§

fn vzip(self) -> V