pub struct Package { /* private fields */ }Expand description
The raw package: parts, content types, relationships.
Implementations§
Source§impl Package
impl Package
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Opens a package file with positioned reads.
Sourcepub fn from_bytes(bytes: Vec<u8>) -> Result<Self>
pub fn from_bytes(bytes: Vec<u8>) -> Result<Self>
Opens a package held in memory.
Sourcepub fn from_source(source: Arc<dyn Source>) -> Result<Self>
pub fn from_source(source: Arc<dyn Source>) -> Result<Self>
Opens a package over any positioned source.
pub fn from_archive(archive: Archive) -> Result<Self>
Sourcepub fn seed(&self) -> PackageSeed
pub fn seed(&self) -> PackageSeed
A handle that can cross threads; see Package::from_seed.
Sourcepub fn from_seed(seed: PackageSeed) -> Self
pub fn from_seed(seed: PackageSeed) -> Self
A package sharing the archive and parsed directory of seed, with its own caches.
pub fn archive(&self) -> &Archive
pub fn content_types(&self) -> &ContentTypes
pub fn defects(&self) -> &PackageDefects
Sourcepub fn part_index(&self, name: &str) -> Option<usize>
pub fn part_index(&self, name: &str) -> Option<usize>
The index of the part named name, compared ASCII case-insensitively.
pub fn has_part(&self, name: &str) -> bool
Sourcepub fn content_type_of(&self, name: &str) -> Option<&str>
pub fn content_type_of(&self, name: &str) -> Option<&str>
The declared content type of name (7.2.3.5).
Sourcepub fn read_part(&self, name: &str) -> Result<Rc<Vec<u8>>>
pub fn read_part(&self, name: &str) -> Result<Rc<Vec<u8>>>
The decompressed bytes of a part, cached for the life of this package.
Sourcepub fn read_part_into(&self, name: &str, out: &mut Vec<u8>) -> Result<()>
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.
Sourcepub fn read_part_bytes(&self, name: &str, out: &mut Vec<u8>) -> Result<()>
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.
Sourcepub fn rels(&self, source: &str) -> Result<Rc<Relationships>>
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.