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
use lopdf;
use std::collections::HashMap;

/// __STUB__
#[derive(Default, Debug, Copy, Clone)]
pub struct Pattern {}

impl Pattern {
    /// Creates a new Pattern
    pub fn new() -> Self {
        Self::default()
    }
}

/// Named reference to a pattern
#[derive(Debug)]
pub struct PatternRef {
    pub(crate) name: String,
}

impl PatternRef {
    pub fn new(index: usize) -> Self {
        Self {
            name: format!("PT{index}"),
        }
    }
}

#[derive(Default, Debug, Clone)]
pub struct PatternList {
    patterns: HashMap<String, Pattern>,
}

impl PatternList {
    /// Creates a new pattern list
    pub fn new() -> Self {
        Self {
            patterns: HashMap::new(),
        }
    }

    /// Adds a new pattern to the pattern list
    pub fn add_pattern(&mut self, pattern: Pattern) -> PatternRef {
        let len = self.patterns.len();
        let pattern_ref = PatternRef::new(len);
        self.patterns.insert(pattern_ref.name.clone(), pattern);
        pattern_ref
    }
}

impl From<PatternList> for lopdf::Dictionary {
    fn from(_val: PatternList) -> Self {
        // todo
        lopdf::Dictionary::new()
    }
}