pub struct DocumentProperties {
pub title: Option<String>,
pub subject: Option<String>,
pub creator: Option<String>,
pub keywords: Option<String>,
pub description: Option<String>,
pub last_modified_by: Option<String>,
pub revision: Option<String>,
pub created: Option<String>,
pub modified: Option<String>,
pub category: Option<String>,
pub content_status: Option<String>,
}Expand description
This document’s core properties (docProps/core.xml, CT_CoreProperties). Every field mirrors
a Dublin Core / Dublin Core Terms element Word’s own File > Info panel shows and lets a user
edit — None leaves the corresponding XML element out entirely (mirrors Word’s own behavior: an
absent element is treated as an empty property, not a validation error). Dates
(created/modified) are plain ISO-8601/W3CDTF strings (e.g. "2026-07-17T10:00:00Z"), not a
dedicated date/time type — this crate has no date/time dependency, and two optional metadata
fields don’t justify adding one; the caller is responsible for supplying a valid W3CDTF string,
not validated when writing (same best-effort posture as Paragraph.numbering_id referencing a
declaration that may not exist). A handful of CT_CoreProperties’ children are not modeled here
(dc:identifier, dc:language, cp:lastPrinted, cp:version) — niche fields with no real
demand seen yet, same scope-reduction posture as elsewhere in this crate.
Fields§
§title: Option<String>The document’s title (dc:title), shown in Word’s title bar and File > Info panel.
subject: Option<String>The document’s subject (dc:subject).
creator: Option<String>The document’s author (dc:creator).
keywords: Option<String>Search keywords/tags (cp:keywords).
description: Option<String>A longer description of the document (dc:description) — shown as “Comments” in Word’s own
File > Info panel despite the underlying element being dc:description.
last_modified_by: Option<String>The user who last modified the document (cp:lastModifiedBy).
revision: Option<String>The document’s revision number, as a plain string (cp:revision, schema-typed as
xsd:string, even though Word itself always populates it with a decimal integer in
practice).
created: Option<String>When the document was created (dcterms:created), a W3CDTF string. See this struct’s own
doc comment for the string-not-a-type choice.
modified: Option<String>When the document was last modified (dcterms:modified), mirroring created.
category: Option<String>The document’s category (cp:category), a free-form classification string distinct from
subject.
content_status: Option<String>The document’s content status (cp:contentStatus, e.g. “Draft”, “Final” — a free-form
string, not a fixed enumeration).
Implementations§
Source§impl DocumentProperties
impl DocumentProperties
Sourcepub fn new() -> DocumentProperties
pub fn new() -> DocumentProperties
Creates an empty set of document 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_title(self, title: impl Into<String>) -> DocumentProperties
pub fn with_title(self, title: impl Into<String>) -> DocumentProperties
Sets the document’s title 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_subject(self, subject: impl Into<String>) -> DocumentProperties
pub fn with_subject(self, subject: impl Into<String>) -> DocumentProperties
Sets the document’s subject 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_creator(self, creator: impl Into<String>) -> DocumentProperties
pub fn with_creator(self, creator: impl Into<String>) -> DocumentProperties
Sets the document’s author 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_keywords(self, keywords: impl Into<String>) -> DocumentProperties
pub fn with_keywords(self, keywords: impl Into<String>) -> DocumentProperties
Sets the document’s search keywords 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_description(
self,
description: impl Into<String>,
) -> DocumentProperties
pub fn with_description( self, description: impl Into<String>, ) -> DocumentProperties
Sets the document’s description and returns it for chaining. Shown as “Comments” in Word’s own File > Info panel — see this field’s doc comment.
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_last_modified_by(
self,
last_modified_by: impl Into<String>,
) -> DocumentProperties
pub fn with_last_modified_by( self, last_modified_by: impl Into<String>, ) -> DocumentProperties
Sets who last modified the document and returns it for chaining.
Sourcepub fn with_revision(self, revision: impl Into<String>) -> DocumentProperties
pub fn with_revision(self, revision: impl Into<String>) -> DocumentProperties
Sets the document’s revision number (as a string) and returns it for chaining.
Sourcepub fn with_created(self, created: impl Into<String>) -> DocumentProperties
pub fn with_created(self, created: impl Into<String>) -> DocumentProperties
Sets when the document was created (a W3CDTF string, e.g. "2026-07-17T10:00:00Z") and
returns it for chaining. Not validated — see this struct’s doc comment.
Sourcepub fn with_modified(self, modified: impl Into<String>) -> DocumentProperties
pub fn with_modified(self, modified: impl Into<String>) -> DocumentProperties
Sets when the document was last modified (a W3CDTF string), mirroring with_created, and
returns it for chaining.
Sourcepub fn with_category(self, category: impl Into<String>) -> DocumentProperties
pub fn with_category(self, category: impl Into<String>) -> DocumentProperties
Sets the document’s category 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_content_status(
self,
content_status: impl Into<String>,
) -> DocumentProperties
pub fn with_content_status( self, content_status: impl Into<String>, ) -> DocumentProperties
Sets the document’s content status (e.g. "Draft", "Final") 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 DocumentProperties
impl Clone for DocumentProperties
Source§fn clone(&self) -> DocumentProperties
fn clone(&self) -> DocumentProperties
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 DocumentProperties
impl Debug for DocumentProperties
Source§impl Default for DocumentProperties
impl Default for DocumentProperties
Source§fn default() -> DocumentProperties
fn default() -> DocumentProperties
impl Eq for DocumentProperties
Source§impl PartialEq for DocumentProperties
impl PartialEq for DocumentProperties
impl StructuralPartialEq for DocumentProperties
Auto Trait Implementations§
impl Freeze for DocumentProperties
impl RefUnwindSafe for DocumentProperties
impl Send for DocumentProperties
impl Sync for DocumentProperties
impl Unpin for DocumentProperties
impl UnsafeUnpin for DocumentProperties
impl UnwindSafe for DocumentProperties
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.