Skip to main content

WmlDocument

Struct WmlDocument 

Source
pub struct WmlDocument {
    pub file_name: String,
    /* private fields */
}
Expand description

A WordprocessingML document held as its package bytes plus the main document part parsed on demand. Mirrors the C# WmlDocument (DocumentByteArray + lazy MainDocumentPart) used by the crate::comparer pipeline.

Constructed with Self::from_bytes (which admits under InputLimits::compare); reads and edits go through Self::dom / Self::dom_mut and Self::part_fs / Self::part_fs_mut.

Fields§

§file_name: String

FileName — the inherited WmlDocument property, kept as a free string for callers that gather metrics or build paths from it.

Implementations§

Source§

impl WmlDocument

Source

pub fn from_bytes(bytes: &[u8]) -> Result<WmlDocument, OpcError>

Opens bytes as a .docx, admits it under InputLimits::compare, and lazily parses the main document part on the first Self::main_document call.

§Errors
Source

pub fn bytes(&self) -> &[u8] ⓘ

The bytes the document was opened from. Edits through Self::part_fs_mut or Self::dom_mut do not show here; repack through crate::opc::PartFs::to_zip to get the new bytes.

Source

pub fn main_document_part_name(&self) -> String

The main document part name (word/document.xml unless OPC relationships name otherwise). The string always returned even when the part is absent.

Source

pub fn main_document(&mut self) -> Result<NodeId, OpcError>

Parses the main document part (once) and returns its document node. Subsequent calls return the cached node.

§Errors

OpcError::PartNotFound when the package has no part at Self::main_document_part_name (the body the comparer would diff into is missing).

Source

pub fn main_document_root(&mut self) -> Result<NodeId, OpcError>

The root element (<w:document>) of the main document part.

§Errors

OpcError::PartNotFound when the part is absent, or the parsed XML has no root element.

Source

pub fn dom(&self) -> &Dom

The arena DOM (read-only). Empty until a successful Self::main_document parses the part into it.

Source

pub fn dom_mut(&mut self) -> &mut Dom

The arena DOM (mutable). The comparer mutates this DOM while it produces the body diff.

Source

pub fn part_fs(&self) -> &PartFs

The opened OPC package (read-only), by which every other part and relationship is read.

Source

pub fn part_fs_mut(&mut self) -> &mut PartFs

The opened OPC package (mutable).

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.