Skip to main content

ExtendedProperties

Struct ExtendedProperties 

Source
pub struct ExtendedProperties {
    pub company: Option<String>,
    pub manager: Option<String>,
}
Expand description

This document’s extended properties (docProps/app.xml, CT_Properties — confirmed via ECMA-376’s own schema fragment to be an xsd:all group, same “no fixed order” shape as CT_CoreProperties). Only Company/Manager are modeled here: the two fields a user actually edits (shown right next to Title/Author/Category in Word’s own Summary tab, alongside the docProps/core.xml fields already modeled by DocumentProperties). CT_Properties has many more children (Words, Pages, Characters, Lines, Paragraphs, TotalTime, Application, AppVersion, DocSecurity, ScaleCrop, LinksUpToDate..) — these are statistics/environment fields Word itself computes when it saves a document, not meaningful for a generation library to set by hand, so they’re deliberately left out (this crate’s writer.rs still always sets Application to identify itself as the producer, same as before this struct existed, but that value isn’t exposed as a settable field here).

Fields§

§company: Option<String>

The document’s associated company/organization (Company).

§manager: Option<String>

The document’s manager (Manager).

Implementations§

Source§

impl ExtendedProperties

Source

pub fn new() -> ExtendedProperties

Creates an empty set of extended properties (every field None).

Examples found in repository?
examples/docx_metadata_and_protection.rs (line 25)
16fn main() -> office_toolkit::Result<()> {
17    let properties = DocumentProperties::new()
18        .with_title("Quarterly Report")
19        .with_subject("Q3 results")
20        .with_creator("Jane Doe")
21        .with_keywords("finance, quarterly, report")
22        .with_description("An example document showing document properties.")
23        .with_category("Finance")
24        .with_content_status("Draft");
25    let extended_properties = ExtendedProperties::new()
26        .with_company("Acme Corp.")
27        .with_manager("Jane Manager");
28
29    let metadata_document = Document::new()
30        .with_properties(properties)
31        .with_extended_properties(extended_properties)
32        .with_custom_property("ProjectCode", CustomPropertyValue::Text("Q3-2026".to_string()))
33        .with_custom_property("Budget", CustomPropertyValue::Number(125_000.0))
34        .with_custom_property("Approved", CustomPropertyValue::Bool(false))
35        .with_custom_property("RevisionCount", CustomPropertyValue::Int(3))
36        .with_track_changes(true)
37        .with_paragraph(Paragraph::with_text(
38            "This document carries standard properties (title/author/subject/...), four custom properties, \
39             and has track changes turned on — check File > Info in Word to see them.",
40        ));
41    let metadata_path = output_path("docx_metadata.docx");
42    metadata_document.save_to_file(&metadata_path)?;
43    println!("Wrote {}", metadata_path.display());
44
45    let protected_document = Document::new()
46        .with_protection(ProtectionKind::ReadOnly)
47        .with_paragraph(Paragraph::with_text(
48            "This document is protected as read-only — Word will ask for a password before allowing edits.",
49        ));
50    let protected_path = output_path("docx_protected.docx");
51    protected_document.save_to_file(&protected_path)?;
52    println!("Wrote {}", protected_path.display());
53
54    Ok(())
55}
Source

pub fn with_company(self, company: impl Into<String>) -> ExtendedProperties

Sets the document’s company and returns it for chaining.

Examples found in repository?
examples/docx_metadata_and_protection.rs (line 26)
16fn main() -> office_toolkit::Result<()> {
17    let properties = DocumentProperties::new()
18        .with_title("Quarterly Report")
19        .with_subject("Q3 results")
20        .with_creator("Jane Doe")
21        .with_keywords("finance, quarterly, report")
22        .with_description("An example document showing document properties.")
23        .with_category("Finance")
24        .with_content_status("Draft");
25    let extended_properties = ExtendedProperties::new()
26        .with_company("Acme Corp.")
27        .with_manager("Jane Manager");
28
29    let metadata_document = Document::new()
30        .with_properties(properties)
31        .with_extended_properties(extended_properties)
32        .with_custom_property("ProjectCode", CustomPropertyValue::Text("Q3-2026".to_string()))
33        .with_custom_property("Budget", CustomPropertyValue::Number(125_000.0))
34        .with_custom_property("Approved", CustomPropertyValue::Bool(false))
35        .with_custom_property("RevisionCount", CustomPropertyValue::Int(3))
36        .with_track_changes(true)
37        .with_paragraph(Paragraph::with_text(
38            "This document carries standard properties (title/author/subject/...), four custom properties, \
39             and has track changes turned on — check File > Info in Word to see them.",
40        ));
41    let metadata_path = output_path("docx_metadata.docx");
42    metadata_document.save_to_file(&metadata_path)?;
43    println!("Wrote {}", metadata_path.display());
44
45    let protected_document = Document::new()
46        .with_protection(ProtectionKind::ReadOnly)
47        .with_paragraph(Paragraph::with_text(
48            "This document is protected as read-only — Word will ask for a password before allowing edits.",
49        ));
50    let protected_path = output_path("docx_protected.docx");
51    protected_document.save_to_file(&protected_path)?;
52    println!("Wrote {}", protected_path.display());
53
54    Ok(())
55}
Source

pub fn with_manager(self, manager: impl Into<String>) -> ExtendedProperties

Sets the document’s manager and returns it for chaining.

Examples found in repository?
examples/docx_metadata_and_protection.rs (line 27)
16fn main() -> office_toolkit::Result<()> {
17    let properties = DocumentProperties::new()
18        .with_title("Quarterly Report")
19        .with_subject("Q3 results")
20        .with_creator("Jane Doe")
21        .with_keywords("finance, quarterly, report")
22        .with_description("An example document showing document properties.")
23        .with_category("Finance")
24        .with_content_status("Draft");
25    let extended_properties = ExtendedProperties::new()
26        .with_company("Acme Corp.")
27        .with_manager("Jane Manager");
28
29    let metadata_document = Document::new()
30        .with_properties(properties)
31        .with_extended_properties(extended_properties)
32        .with_custom_property("ProjectCode", CustomPropertyValue::Text("Q3-2026".to_string()))
33        .with_custom_property("Budget", CustomPropertyValue::Number(125_000.0))
34        .with_custom_property("Approved", CustomPropertyValue::Bool(false))
35        .with_custom_property("RevisionCount", CustomPropertyValue::Int(3))
36        .with_track_changes(true)
37        .with_paragraph(Paragraph::with_text(
38            "This document carries standard properties (title/author/subject/...), four custom properties, \
39             and has track changes turned on — check File > Info in Word to see them.",
40        ));
41    let metadata_path = output_path("docx_metadata.docx");
42    metadata_document.save_to_file(&metadata_path)?;
43    println!("Wrote {}", metadata_path.display());
44
45    let protected_document = Document::new()
46        .with_protection(ProtectionKind::ReadOnly)
47        .with_paragraph(Paragraph::with_text(
48            "This document is protected as read-only — Word will ask for a password before allowing edits.",
49        ));
50    let protected_path = output_path("docx_protected.docx");
51    protected_document.save_to_file(&protected_path)?;
52    println!("Wrote {}", protected_path.display());
53
54    Ok(())
55}

Trait Implementations§

Source§

impl Clone for ExtendedProperties

Source§

fn clone(&self) -> ExtendedProperties

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExtendedProperties

Source§

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

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

impl Default for ExtendedProperties

Source§

fn default() -> ExtendedProperties

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

impl Eq for ExtendedProperties

Source§

impl PartialEq for ExtendedProperties

Source§

fn eq(&self, other: &ExtendedProperties) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ExtendedProperties

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.