Skip to main content

ekg_identifier/ekg_identifier_context/
mod.rs

1use {
2    crate::{iri::ABoxNamespaceIRI, mandatory_env_var_base_iri},
3    ekg_error::Error,
4};
5
6pub struct EkgIdentifierContext {
7    pub ekg_base:          ABoxNamespaceIRI,
8    pub ekg_id_base:       ABoxNamespaceIRI,
9    pub ekg_graph_base:    ABoxNamespaceIRI,
10    pub ekg_ontology_base: ABoxNamespaceIRI,
11}
12
13impl EkgIdentifierContext {
14    pub fn from_env(suffix: &'static str) -> Result<Self, Error> {
15        Ok(Self {
16            ekg_base:          mandatory_env_var_base_iri("EKG_BASE", Some(suffix))?,
17            ekg_id_base:       mandatory_env_var_base_iri("EKG_ID_BASE", Some(suffix))?,
18            ekg_graph_base:    mandatory_env_var_base_iri("EKG_GRAPH_BASE", Some(suffix))?,
19            ekg_ontology_base: mandatory_env_var_base_iri("EKG_ONTOLOGY_BASE", Some(suffix))?,
20        })
21    }
22}
23
24pub struct EkgIdentifierContexts {
25    pub internal: EkgIdentifierContext,
26    pub external: EkgIdentifierContext,
27}
28
29impl EkgIdentifierContexts {
30    pub fn from_env() -> Result<Self, Error> {
31        Ok(Self {
32            internal: EkgIdentifierContext::from_env("_INTERNAL")?,
33            external: EkgIdentifierContext::from_env("_EXTERNAL")?,
34        })
35    }
36}