docx_reader/documents/elements/
table_of_contents_item.rs

1use serde::Serialize;
2
3use crate::documents::*;
4
5#[derive(Serialize, Debug, Clone, PartialEq, Default)]
6pub struct TableOfContentsItem {
7	pub instr: InstrToC,
8	pub text: String,
9	pub toc_key: String,
10	pub level: usize,
11	pub dirty: bool,
12	pub page_ref: Option<String>,
13}
14
15impl TableOfContentsItem {
16	pub fn new() -> Self {
17		Self {
18			level: 1,
19			..Default::default()
20		}
21	}
22
23	pub fn instr(mut self, instr: InstrToC) -> Self {
24		self.instr = instr;
25		self
26	}
27
28	pub fn text(mut self, text: impl Into<String>) -> Self {
29		self.text = text.into();
30		self
31	}
32
33	pub fn level(mut self, level: usize) -> Self {
34		self.level = level;
35		self
36	}
37
38	pub fn toc_key(mut self, key: impl Into<String>) -> Self {
39		self.toc_key = key.into();
40		self
41	}
42
43	pub fn page_ref(mut self, r: impl Into<String>) -> Self {
44		self.page_ref = Some(r.into());
45		self
46	}
47}