Skip to main content

graphitepdf_kit/
metadata.rs

1#[derive(Clone, Debug, Default)]
2pub struct Metadata {
3    pub title: Option<String>,
4    pub author: Option<String>,
5    pub subject: Option<String>,
6    pub keywords: Vec<String>,
7    pub creator: Option<String>,
8    pub producer: Option<String>,
9    pub creation_date: Option<String>,
10    pub mod_date: Option<String>,
11}
12
13impl Metadata {
14    pub fn new() -> Self {
15        Self::default()
16    }
17
18    pub fn title(mut self, title: impl Into<String>) -> Self {
19        self.title = Some(title.into());
20        self
21    }
22
23    pub fn author(mut self, author: impl Into<String>) -> Self {
24        self.author = Some(author.into());
25        self
26    }
27
28    pub fn subject(mut self, subject: impl Into<String>) -> Self {
29        self.subject = Some(subject.into());
30        self
31    }
32
33    pub fn keywords(mut self, keywords: impl IntoIterator<Item = impl Into<String>>) -> Self {
34        self.keywords = keywords.into_iter().map(|k| k.into()).collect();
35        self
36    }
37
38    pub fn creator(mut self, creator: impl Into<String>) -> Self {
39        self.creator = Some(creator.into());
40        self
41    }
42
43    pub fn producer(mut self, producer: impl Into<String>) -> Self {
44        self.producer = Some(producer.into());
45        self
46    }
47}