Skip to main content

ZipPackageSource

Struct ZipPackageSource 

Source
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

Source

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.

Source

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.

Source

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

Parse a DOCX package from raw bytes.

Trait Implementations§

Source§

impl Debug for ZipPackageSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PackageSource for ZipPackageSource

Source§

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>

Return true if the named part exists in this package.
Source§

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

Read the raw bytes of a part, or None if the part does not exist.
Source§

fn raw_archive_bytes(&self) -> Option<&[u8]>

Return the raw bytes of the underlying archive, if available. Read more

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> 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 = !

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.