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 {
10 pub all: BTreeMap<String, String>,
12 pub reserved: BTreeMap<String, String>,
14 pub preferences: BTreeMap<String, String>,
16 pub components: BTreeMap<String, String>,
18 pub entities: BTreeMap<String, String>,
20 pub generic_properties: BTreeMap<String, String>,
22 pub ipv4: BTreeMap<String, String>,
24 pub ipv6: BTreeMap<String, String>,
26 pub dns: BTreeMap<String, String>,
28 pub proxies: BTreeMap<String, String>,
30 pub interface_types: BTreeMap<String, String>,
32}
33
34impl SchemaCatalog {
35 pub fn get(&self, symbol: &str) -> Option<&str> {
37 self.all.get(symbol).map(String::as_str)
38 }
39
40 pub fn contains(&self, symbol: &str) -> bool {
42 self.all.contains_key(symbol)
43 }
44}
45
46#[derive(Clone, Copy, Debug, Default)]
47pub struct Schema;
49
50impl Schema {
51 pub fn catalog() -> Result<SchemaCatalog> {
53 bridge::parse_json("sc_schema_copy_catalog", unsafe {
54 ffi::schema::sc_schema_copy_catalog()
55 })
56 }
57}