Skip to main content

Body

Struct Body 

Source
pub struct Body {
    pub block_content: Vec<BlockContent>,
    pub sect_pr: Option<Box<SectionProperties>>,
    pub extra_children: Vec<PositionedNode>,
}

Fields§

§block_content: Vec<BlockContent>§sect_pr: Option<Box<SectionProperties>>§extra_children: Vec<PositionedNode>

Unknown child elements captured for roundtrip fidelity.

Implementations§

Source§

impl Body

Source

pub fn add_paragraph(&mut self) -> &mut Paragraph

Add an empty paragraph and return a mutable reference to it.

Source

pub fn add_table(&mut self) -> &mut Table

Add an empty table and return a mutable reference to it.

Source

pub fn set_section_properties(&mut self, sect_pr: SectionProperties)

Set section properties on the body.

Source§

impl Body

Source

pub fn add_form_field(&mut self, config: FormFieldConfig) -> &mut Self

Add a form field as a Structured Document Tag (<w:sdt>).

Produces a block-level SDT containing an appropriate SDT properties element (<w:sdtPr>) and content paragraph with the default value.

ECMA-376 Part 1, Section 17.5.2.

Source§

impl Body

Source

pub fn add_toc(&mut self, opts: TocOptions) -> &mut Self

Insert a Table of Contents field at the current position.

This writes:

  1. An optional title paragraph styled “TOC Heading”.
  2. A TOC field spanning three paragraphs: fldChar begin, instrText, fldChar end.
  3. A placeholder paragraph telling the user to update the field.

ECMA-376 Part 1, Section 17.16.5.58 (TOC).

Trait Implementations§

Source§

impl BodyExt for Body

Source§

fn paragraphs(&self) -> Vec<&Paragraph>

Get all paragraphs in the body.
Source§

fn tables(&self) -> Vec<&Table>

Get all tables in the body.
Source§

fn text(&self) -> String

Extract all text content from the body.
Source§

fn section_properties(&self) -> Option<&SectionProperties>

Get the document-level section properties (layout info).
Source§

fn table_of_contents(&self) -> Vec<TableOfContents>

Extract all Tables of Contents from this body. Read more
Source§

fn form_fields(&self) -> Vec<FormField>

Extract all form fields from this body (ECMA-376 §17.5.2). Read more
Source§

impl BodyRevisionExt for Body

Available on crate feature wml-track-changes only.
Source§

fn all_track_changes(&self) -> Vec<TrackChange>

All tracked changes in the document body across all paragraphs.
Source§

fn accepted_text(&self) -> String

Full document text with all insertions accepted and deletions removed.
Source§

fn rejected_text(&self) -> String

Full document text with all insertions rejected and deletions restored.
Source§

impl Clone for Body

Source§

fn clone(&self) -> Body

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Body

Source§

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

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

impl Default for Body

Source§

fn default() -> Body

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Body

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromXml for Body

Source§

fn from_xml<R: BufRead>( reader: &mut Reader<R>, start_tag: &BytesStart<'_>, is_empty: bool, ) -> Result<Self, ParseError>

Parse from an XML reader positioned at the start tag. Read more
Source§

impl MathExt for Body

Available on crate feature extra-children only.
Source§

fn math_expressions(&self) -> Vec<MathExpression>

Return all math expressions contained in this element.
Source§

fn has_math(&self) -> bool

Return true if this element contains at least one math expression.
Source§

impl Serialize for Body

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToXml for Body

Source§

fn write_children<W: Write>( &self, writer: &mut Writer<W>, ) -> Result<(), SerializeError>

Write child elements and text content inside the element.
Source§

fn is_empty_element(&self) -> bool

Whether this element has no children (self-closing).
Source§

fn write_attrs<'a>(&self, start: BytesStart<'a>) -> BytesStart<'a>

Write attributes onto the start tag and return it.
Source§

fn write_element<W>( &self, tag: &str, writer: &mut Writer<W>, ) -> Result<(), SerializeError>
where W: Write,

Write a complete element: <tag attrs>children</tag> or <tag attrs/>.

Auto Trait Implementations§

§

impl Freeze for Body

§

impl RefUnwindSafe for Body

§

impl Send for Body

§

impl Sync for Body

§

impl Unpin for Body

§

impl UnsafeUnpin for Body

§

impl UnwindSafe for Body

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,