Skip to main content

Package

Struct Package 

Source
pub struct Package { /* private fields */ }
Expand description

The raw package: parts, content types, relationships.

Implementations§

Source§

impl Package

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Opens a package file with positioned reads.

Source

pub fn from_bytes(bytes: Vec<u8>) -> Result<Self>

Opens a package held in memory.

Source

pub fn from_source(source: Arc<dyn Source>) -> Result<Self>

Opens a package over any positioned source.

Source

pub fn from_archive(archive: Archive) -> Result<Self>

Source

pub fn seed(&self) -> PackageSeed

A handle that can cross threads; see Package::from_seed.

Source

pub fn from_seed(seed: PackageSeed) -> Self

A package sharing the archive and parsed directory of seed, with its own caches.

Source

pub fn archive(&self) -> &Archive

Source

pub fn parts(&self) -> &[Part]

Every part in archive order.

Source

pub fn content_types(&self) -> &ContentTypes

Source

pub fn defects(&self) -> &PackageDefects

Source

pub fn part_index(&self, name: &str) -> Option<usize>

The index of the part named name, compared ASCII case-insensitively.

Source

pub fn has_part(&self, name: &str) -> bool

Source

pub fn part(&self, name: &str) -> Option<&Part>

The part as written, found case-insensitively.

Source

pub fn entry(&self, name: &str) -> Option<&Entry>

The archive entry backing name.

Source

pub fn content_type_of(&self, name: &str) -> Option<&str>

The declared content type of name (7.2.3.5).

Source

pub fn read_part(&self, name: &str) -> Result<Rc<Vec<u8>>>

The decompressed bytes of a part, cached for the life of this package.

Source

pub fn read_part_into(&self, name: &str, out: &mut Vec<u8>) -> Result<()>

The decompressed bytes of a part into out, bypassing the cache. Interleaved pieces are concatenated; a UTF-16 XML part comes back as UTF-8.

Source

pub fn read_part_bytes(&self, name: &str, out: &mut Vec<u8>) -> Result<()>

The decompressed bytes of a part exactly as stored (pieces concatenated), without the UTF-16 transcoding of Package::read_part.

Source

pub fn rels(&self, source: &str) -> Result<Rc<Relationships>>

The relationships of source (/ for the package). A missing Relationships part yields an empty set; a malformed one is an error.

Source

pub fn package_rels(&self) -> Result<Rc<Relationships>>

Source

pub fn resolve(&self, source: &str, id: &str) -> Result<Option<String>>

The part name relationship id of source points at, when internal.

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.