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
/// JSON-LD serializer configuration.
#[derive(Clone, Debug, Default)]
pub struct JsonLdConfig {
    pub rdf_direction: Option<RdfDirectionMode>,
    pub spaces: u16,
    pub spec_version: JsonLdSpecVersion,
    pub use_native_types: bool,
    pub use_rdf_type: bool,
}

impl JsonLdConfig {
    pub fn new() -> Self {
        Self::default()
    }

    pub fn spaces(mut self, spaces: u16) -> Self {
        self.spaces = spaces;
        self
    }

    pub fn spec_version(mut self, version: JsonLdSpecVersion) -> Self {
        self.spec_version = version;
        self
    }

    pub fn use_native_types(mut self, flag: bool) -> Self {
        self.use_native_types = flag;
        self
    }

    pub fn use_rdf_type(mut self, flag: bool) -> Self {
        self.use_rdf_type = flag;
        self
    }
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum JsonLdSpecVersion {
    JsonLd10,
    JsonLd11,
}

impl Default for JsonLdSpecVersion {
    fn default() -> Self {
        JsonLdSpecVersion::JsonLd11
    }
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum RdfDirectionMode {
    I18nDatatype,
    CompoundLiteral,
}