libpna

Struct SolidArchive

Source
pub struct SolidArchive<T: Write> { /* private fields */ }
Expand description

An object providing writing to a solid mode PNA file. An instance of an SolidArchive can be written.

§Examples

Creates a new solid mode PNA file and adds entry to it.

use libpna::{Archive, EntryBuilder, WriteOptions};
use std::fs::File;

let option = WriteOptions::builder().build();
let file = File::create("foo.pna")?;
let mut archive = Archive::write_solid_header(file, option)?;
let mut entry_builder = EntryBuilder::new_file("bar.txt".into(), WriteOptions::store())?;
entry_builder.write_all(b"content")?;
let entry = entry_builder.build()?;
archive.add_entry(entry)?;
archive.finalize()?;

Implementations§

Source§

impl<W: Write> SolidArchive<W>

Source

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

Adds a new entry to the archive.

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

let option = WriteOptions::builder().build();
let file = File::create("example.pna")?;
let mut archive = Archive::write_solid_header(file, option)?;
archive
    .add_entry(EntryBuilder::new_file("example.txt".into(), WriteOptions::store())?.build()?)?;
archive.finalize()?;
Source

pub fn write_file<F>( &mut self, name: EntryName, metadata: Metadata, f: F, ) -> Result<()>
where F: FnMut(&mut SolidArchiveEntryDataWriter<'_, W>) -> Result<()>,

Write a regular file as solid entry into archive.

§Example
use libpna::{Archive, Metadata, WriteOptions};
use std::fs;
use std::io::{self, prelude::*};

let file = fs::File::create("foo.pna")?;
let option = WriteOptions::builder().build();
let mut archive = Archive::write_solid_header(file, option)?;
archive.write_file("bar.txt".into(), Metadata::new(), |writer| {
    writer.write_all(b"text")
})?;
archive.finalize()?;
Source

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

Write an end marker to finalize the archive.

Marks that the PNA archive contains no more entries. Normally, a PNA archive reader will continue reading entries in the hope that the entry exists until it encounters this end marker. This end marker should always be recorded at the end of the file unless there is a special reason to do so.

§Examples

Create an empty archive.

use libpna::{Archive, WriteOptions};
use std::fs::File;

let option = WriteOptions::builder().build();
let file = File::create("example.pna")?;
let mut archive = Archive::write_solid_header(file, option)?;
archive.finalize()?;

Auto Trait Implementations§

§

impl<T> Freeze for SolidArchive<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SolidArchive<T>
where T: RefUnwindSafe,

§

impl<T> Send for SolidArchive<T>
where T: Send,

§

impl<T> Sync for SolidArchive<T>
where T: Sync,

§

impl<T> Unpin for SolidArchive<T>
where T: Unpin,

§

impl<T> !UnwindSafe for SolidArchive<T>

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> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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