Skip to main content

bynk_check/
builtin_names.rs

1//! Centralised string literals for the language's built-in vocabulary (refactor
2//! track item 8, v0.29.11). Built-in type/method names were compared as bare
3//! string literals scattered across the checker, emitter, and project modules;
4//! a typo was a silent never-match. One edit point per name now.
5
6/// Built-in type names (as they appear in source / qualified positions).
7pub mod types {
8    pub const JSON: &str = "Json";
9    pub const LIST: &str = "List";
10    pub const MAP: &str = "Map";
11    pub const INT: &str = "Int";
12    pub const FLOAT: &str = "Float";
13    pub const DURATION: &str = "Duration";
14    pub const INSTANT: &str = "Instant";
15    pub const BYTES: &str = "Bytes";
16    /// #2341 (L4): an HTTP handler's read-only view of the request's headers.
17    pub const REQUEST_HEADERS: &str = "RequestHeaders";
18    /// #2380 (L5): an `Oidc` actor's verified token claims.
19    pub const TOKEN_CLAIMS: &str = "TokenClaims";
20    pub const HTTP_RESULT: &str = "HttpResult";
21    pub const QUEUE_RESULT: &str = "QueueResult";
22    pub const STREAM: &str = "Stream";
23    /// The compiler-known entry record a map's `.entries` query yields
24    /// (v0.158, ADR 0184). A nominal generic record `{ key: K, value: V }`
25    /// — bynk stays nominal (ADR 0120), so a map entry is a named record, not
26    /// an anonymous pair. Non-boundary like every generic-record instantiation
27    /// (ADR 0183): project it through `.map` into a named type before a
28    /// terminal that leaves the pipeline.
29    pub const MAP_ENTRY: &str = "MapEntry";
30}
31
32/// The `.entries` / `.keys` / `.values` accessors a `store Map[K, V]` field
33/// exposes as lazy queries (v0.158, ADR 0184), and the two fields the
34/// `MapEntry` record carries.
35pub mod map_query {
36    /// `map.entries : Query[MapEntry[K, V]]`.
37    pub const ENTRIES: &str = "entries";
38    /// `map.keys : Query[K]`.
39    pub const KEYS: &str = "keys";
40    /// `map.values : Query[V]`.
41    pub const VALUES: &str = "values";
42    /// `MapEntry.key : K`.
43    pub const KEY: &str = "key";
44    /// `MapEntry.value : V`.
45    pub const VALUE: &str = "value";
46}
47
48/// Privileged built-in member names — constructors (`of`/`unsafe`), the refined
49/// raw accessor (`raw`), and the effect terminals (`foldEff`/`forEach`).
50pub mod methods {
51    pub const OF: &str = "of";
52    pub const UNSAFE: &str = "unsafe";
53    pub const RAW: &str = "raw";
54    pub const FOLD_EFF: &str = "foldEff";
55    pub const FOR_EACH: &str = "forEach";
56    pub const PAR_TRAVERSE: &str = "parTraverse";
57    pub const TRAVERSE_ALL: &str = "traverseAll";
58    pub const PAR_TRAVERSE_ALL: &str = "parTraverseAll";
59    pub const TRAVERSE_TRY: &str = "traverseTry";
60    pub const PAR_TRAVERSE_TRY: &str = "parTraverseTry";
61}
62
63#[cfg(test)]
64mod tests {
65    use super::*;
66
67    #[test]
68    fn constants_hold_expected_values() {
69        assert_eq!(types::JSON, "Json");
70        assert_eq!(types::HTTP_RESULT, "HttpResult");
71        assert_eq!(methods::OF, "of");
72        assert_eq!(methods::FOLD_EFF, "foldEff");
73        assert_eq!(methods::FOR_EACH, "forEach");
74        assert_eq!(methods::PAR_TRAVERSE, "parTraverse");
75        assert_eq!(methods::TRAVERSE_ALL, "traverseAll");
76        assert_eq!(methods::PAR_TRAVERSE_ALL, "parTraverseAll");
77        assert_eq!(methods::TRAVERSE_TRY, "traverseTry");
78        assert_eq!(methods::PAR_TRAVERSE_TRY, "parTraverseTry");
79    }
80}