shex_ast/ir/
schema.rs

1use iri_s::IriS;
2use prefixmap::PrefixMap;
3use prefixmap::PrefixMapError;
4
5#[derive(Debug)]
6pub struct Schema {
7    pub(crate) id: Option<IriS>,
8    pub(crate) base: Option<IriS>,
9    pub(crate) prefixes: Option<PrefixMap>,
10}
11
12impl Schema {
13    pub fn id(&self) -> Option<IriS> {
14        self.id.clone()
15    }
16
17    pub fn base(&self) -> Option<IriS> {
18        self.base.clone()
19    }
20
21    pub fn resolve(&self, alias: &str) -> Result<Option<IriS>, PrefixMapError> {
22        self.prefixes
23            .as_ref()
24            .map(|pm| pm.resolve(alias))
25            .transpose()
26    }
27}