pub struct DocxReader { /* private fields */ }Expand description
A streaming DOCX reader that implements EventSource.
DocxReader parses a DOCX archive and emits DocSpec events one at a time.
<w:p> paragraphs, <w:t> text, <w:br> line breaks, <w:tab> tabs, and
table elements (<w:tbl>, <w:tr>, <w:tc>) are recognized; all other
elements are silently ignored.
§Streaming
The reader streams document.xml event by event using constant memory.
Only _rels/.rels (a few hundred bytes) is buffered to discover the
document target path.
§Errors
Returns Error::Io for I/O failures and Error::Parse for malformed
archives or XML.
Implementations§
Source§impl DocxReader
impl DocxReader
Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
Creates a DocxReader from a file path.
§Errors
Returns Error::Io if the file cannot be opened. See from_reader
for additional error conditions.
Sourcepub fn from_reader<R: Read + Seek + Send + 'static>(reader: R) -> Result<Self>
pub fn from_reader<R: Read + Seek + Send + 'static>(reader: R) -> Result<Self>
Creates a DocxReader from any Read + Seek source.
The reader must be positioned at the start of a valid DOCX (ZIP) archive.
§Errors
Returns Error::Parse if the input is not a valid ZIP archive, if
_rels/.rels is missing or malformed, or if the document target entry
cannot be opened. Returns Error::Io for I/O failures.