systemconfiguration/
schema.rs1use std::collections::BTreeMap;
2
3use serde::Deserialize;
4
5use crate::{bridge, error::Result, ffi};
6
7#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
8pub struct SchemaCatalog {
9 pub all: BTreeMap<String, String>,
10 pub reserved: BTreeMap<String, String>,
11 pub preferences: BTreeMap<String, String>,
12 pub components: BTreeMap<String, String>,
13 pub entities: BTreeMap<String, String>,
14 pub generic_properties: BTreeMap<String, String>,
15 pub ipv4: BTreeMap<String, String>,
16 pub ipv6: BTreeMap<String, String>,
17 pub dns: BTreeMap<String, String>,
18 pub proxies: BTreeMap<String, String>,
19 pub interface_types: BTreeMap<String, String>,
20}
21
22impl SchemaCatalog {
23 pub fn get(&self, symbol: &str) -> Option<&str> {
24 self.all.get(symbol).map(String::as_str)
25 }
26
27 pub fn contains(&self, symbol: &str) -> bool {
28 self.all.contains_key(symbol)
29 }
30}
31
32#[derive(Clone, Copy, Debug, Default)]
33pub struct Schema;
34
35impl Schema {
36 pub fn catalog() -> Result<SchemaCatalog> {
37 bridge::parse_json("sc_schema_copy_catalog", unsafe { ffi::schema::sc_schema_copy_catalog() })
38 }
39}