docx_reader/documents/doc_props/
core.rs

1use serde::Serialize;
2
3#[derive(Debug, Clone, PartialEq, Serialize)]
4#[serde(rename_all = "camelCase")]
5pub struct CoreProps {
6	config: CorePropsConfig,
7}
8
9#[derive(Debug, Clone, PartialEq, Serialize)]
10#[serde(rename_all = "camelCase")]
11pub struct CorePropsConfig {
12	created: Option<String>,
13	creator: Option<String>,
14	description: Option<String>,
15	language: Option<String>,
16	last_modified_by: Option<String>,
17	modified: Option<String>,
18	revision: Option<usize>,
19	subject: Option<String>,
20	title: Option<String>,
21}
22
23impl Default for CorePropsConfig {
24	fn default() -> Self {
25		Self {
26			created: None,
27			creator: None,
28			description: None,
29			language: None,
30			last_modified_by: None,
31			modified: None,
32			revision: None,
33			subject: None,
34			title: None,
35		}
36	}
37}
38
39impl Default for CoreProps {
40	fn default() -> Self {
41		Self {
42			config: CorePropsConfig::default(),
43		}
44	}
45}
46
47impl CoreProps {
48	pub(crate) fn new(config: CorePropsConfig) -> CoreProps {
49		CoreProps { config }
50	}
51
52	pub fn created_at(mut self, date: &str) -> Self {
53		self.config.created = Some(date.to_owned());
54		self
55	}
56
57	pub fn updated_at(mut self, date: &str) -> Self {
58		self.config.modified = Some(date.to_owned());
59		self
60	}
61}
62
63impl CorePropsConfig {
64	pub fn new() -> Self {
65		CorePropsConfig {
66			created: None,
67			creator: None,
68			description: None,
69			language: None,
70			last_modified_by: None,
71			modified: None,
72			revision: None,
73			subject: None,
74			title: None,
75		}
76	}
77}