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
use crate::DicomObject;
use dicom_dictionary_std::StandardDataDictionary;
use std::marker::PhantomData;

/// A data type
#[derive(Debug)]
pub struct DicomLoaderOptions<D, O> {
    dict: D,
    phantom: PhantomData<O>,
}

impl<'s, O> DicomLoaderOptions<StandardDataDictionary, O>
where
    O: DicomObject,
{
    /// Construct a new DICOM loader with the standard data dictionary.
    pub fn new() -> Self {
        DicomLoaderOptions::default()
    }
}

impl<D, O> Default for DicomLoaderOptions<D, O>
where
    D: Default,
{
    fn default() -> Self {
        DicomLoaderOptions {
            dict: D::default(),
            phantom: PhantomData,
        }
    }
}

impl<'s, D, O> DicomLoaderOptions<D, O>
where
    O: DicomObject,
{
    pub fn with_dict<NewD>(self, dict: NewD) -> DicomLoaderOptions<NewD, O> {
        DicomLoaderOptions {
            dict,
            phantom: PhantomData,
        }
    }

    pub fn with_std_dict(self) -> DicomLoaderOptions<StandardDataDictionary, O> {
        self.with_dict(StandardDataDictionary)
    }
}