pub struct ZipPackageSource { /* private fields */ }Expand description
A DOCX package backed by a ZIP archive.
Constructed via from_path, from_reader, or from_bytes.
All three constructors eagerly build the part-name index so that any
malformed archive or unsafe entry is detected immediately (fail-fast).
Implementations§
Source§impl ZipPackageSource
impl ZipPackageSource
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self>
Open a DOCX file from the file system.
§Errors
Returns an error if the file cannot be read, is not a valid ZIP archive, or contains unsafe entry names.
Sourcepub fn from_reader<R: Read>(reader: R) -> Result<Self>
pub fn from_reader<R: Read>(reader: R) -> Result<Self>
Parse a DOCX package from a Read + Seek source.
The entire stream is read into memory so that individual parts can be re-read on demand without requiring the caller to keep the reader alive.
Sourcepub fn from_bytes(data: Vec<u8>) -> Result<Self>
pub fn from_bytes(data: Vec<u8>) -> Result<Self>
Parse a DOCX package from raw bytes.
Trait Implementations§
Source§impl Debug for ZipPackageSource
impl Debug for ZipPackageSource
Source§impl PackageSource for ZipPackageSource
impl PackageSource for ZipPackageSource
Source§fn part_names(&self) -> Result<Vec<String>>
fn part_names(&self) -> Result<Vec<String>>
Return the names of all parts in this package. Read more
Source§fn contains_part(&self, name: &str) -> Result<bool>
fn contains_part(&self, name: &str) -> Result<bool>
Return
true if the named part exists in this package.Auto Trait Implementations§
impl Forget for ZipPackageSource
impl Freeze for ZipPackageSource
impl Move for ZipPackageSource
impl RefUnwindSafe for ZipPackageSource
impl Send for ZipPackageSourcewhere
RawVecInner: Send,
impl Sync for ZipPackageSourcewhere
RawVecInner: Sync,
impl Unpin for ZipPackageSource
impl UnsafeUnpin for ZipPackageSourcewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for ZipPackageSourcewhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more