docx_reader/documents/doc_props/
core.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use serde::Serialize;

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CoreProps {
	config: CorePropsConfig,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CorePropsConfig {
	created: Option<String>,
	creator: Option<String>,
	description: Option<String>,
	language: Option<String>,
	last_modified_by: Option<String>,
	modified: Option<String>,
	revision: Option<usize>,
	subject: Option<String>,
	title: Option<String>,
}

impl Default for CorePropsConfig {
	fn default() -> Self {
		Self {
			created: None,
			creator: None,
			description: None,
			language: None,
			last_modified_by: None,
			modified: None,
			revision: None,
			subject: None,
			title: None,
		}
	}
}

impl Default for CoreProps {
	fn default() -> Self {
		Self {
			config: CorePropsConfig::default(),
		}
	}
}

impl CoreProps {
	pub(crate) fn new(config: CorePropsConfig) -> CoreProps {
		CoreProps { config }
	}

	pub fn created_at(mut self, date: &str) -> Self {
		self.config.created = Some(date.to_owned());
		self
	}

	pub fn updated_at(mut self, date: &str) -> Self {
		self.config.modified = Some(date.to_owned());
		self
	}
}

impl CorePropsConfig {
	pub fn new() -> Self {
		CorePropsConfig {
			created: None,
			creator: None,
			description: None,
			language: None,
			last_modified_by: None,
			modified: None,
			revision: None,
			subject: None,
			title: None,
		}
	}
}