Skip to main content

sim_lib_search_core/
wire.rs

1use sim_kernel::{Datum, NumberLiteral, Symbol};
2
3/// Stable Shape/Citizen descriptor inventory for general-purpose codecs.
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub struct RecordDescriptor {
6    pub symbol: &'static str,
7    pub version: u32,
8}
9pub const RECORD_DESCRIPTORS: &[RecordDescriptor] = &[
10    RecordDescriptor {
11        symbol: "search/Query",
12        version: 1,
13    },
14    RecordDescriptor {
15        symbol: "search/Site",
16        version: 1,
17    },
18    RecordDescriptor {
19        symbol: "search/ProviderClaim",
20        version: 1,
21    },
22    RecordDescriptor {
23        symbol: "search/Observation",
24        version: 1,
25    },
26    RecordDescriptor {
27        symbol: "search/Page",
28        version: 1,
29    },
30    RecordDescriptor {
31        symbol: "search/Notice",
32        version: 1,
33    },
34    RecordDescriptor {
35        symbol: "search/AliasEvidence",
36        version: 1,
37    },
38    RecordDescriptor {
39        symbol: "search/RankContribution",
40        version: 1,
41    },
42    RecordDescriptor {
43        symbol: "search/Run",
44        version: 1,
45    },
46    RecordDescriptor {
47        symbol: "search/ResearchBundle",
48        version: 1,
49    },
50    RecordDescriptor {
51        symbol: "search/Citation",
52        version: 1,
53    },
54];
55
56pub(crate) fn sym(s: &str) -> Symbol {
57    Symbol::qualified("search", s)
58}
59pub(crate) fn field(n: &str, v: Datum) -> (Symbol, Datum) {
60    (sym(n), v)
61}
62pub(crate) fn node(n: &str, f: Vec<(Symbol, Datum)>) -> Datum {
63    Datum::Node {
64        tag: sym(n),
65        fields: f,
66    }
67}
68pub(crate) fn u32d(v: u32) -> Datum {
69    Datum::Number(NumberLiteral {
70        domain: Symbol::qualified("numbers", "u32"),
71        canonical: v.to_string(),
72    })
73}