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
impl ExtendedProperties
Sourcepub fn new() -> ExtendedProperties
pub fn new() -> ExtendedProperties
Creates an empty set of extended properties (every field None).
Examples found in repository?
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}Sourcepub fn with_company(self, company: impl Into<String>) -> ExtendedProperties
pub fn with_company(self, company: impl Into<String>) -> ExtendedProperties
Sets the document’s company and returns it for chaining.
Examples found in repository?
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}Sourcepub fn with_manager(self, manager: impl Into<String>) -> ExtendedProperties
pub fn with_manager(self, manager: impl Into<String>) -> ExtendedProperties
Sets the document’s manager and returns it for chaining.
Examples found in repository?
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
impl Clone for ExtendedProperties
Source§fn clone(&self) -> ExtendedProperties
fn clone(&self) -> ExtendedProperties
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExtendedProperties
impl Debug for ExtendedProperties
Source§impl Default for ExtendedProperties
impl Default for ExtendedProperties
Source§fn default() -> ExtendedProperties
fn default() -> ExtendedProperties
impl Eq for ExtendedProperties
Source§impl PartialEq for ExtendedProperties
impl PartialEq for ExtendedProperties
impl StructuralPartialEq for ExtendedProperties
Auto Trait Implementations§
impl Freeze for ExtendedProperties
impl RefUnwindSafe for ExtendedProperties
impl Send for ExtendedProperties
impl Sync for ExtendedProperties
impl Unpin for ExtendedProperties
impl UnsafeUnpin for ExtendedProperties
impl UnwindSafe for ExtendedProperties
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.