Skip to main content

mant_protocol/
lib.rs

1#![doc = include_str!("../README.md")]
2#![warn(missing_docs)]
3
4mod catalog;
5mod content_selector;
6mod doctor;
7mod document;
8mod explanation;
9mod kind_labels;
10mod labels;
11mod navigation;
12mod outline;
13mod query;
14mod references;
15mod schema;
16mod scope;
17mod search;
18mod selector;
19mod update;
20
21pub use catalog::*;
22pub use content_selector::*;
23pub use doctor::*;
24pub use document::*;
25pub use explanation::*;
26pub use kind_labels::entry_kind_label;
27pub use labels::{EntryLabelMode, entry_label};
28pub use navigation::DocumentOpenTarget;
29pub use outline::*;
30pub use query::*;
31pub use references::*;
32pub use schema::*;
33pub use scope::*;
34pub use search::*;
35pub use selector::*;
36pub use update::*;
37
38/// Pre-stable native API release line shared by the query protocol family.
39pub const NATIVE_API_VERSION: &str = "0.11";
40
41/// Exact process protocol reported by the native CLI boundary.
42pub const CLI_PROTOCOL_VERSION: &str = "mant.cli/v0.11";
43
44#[cfg(test)]
45mod tests {
46    use super::{
47        CLI_PROTOCOL_VERSION, CatalogSchema, DocumentSchema, ExcerptSchema, NATIVE_API_VERSION,
48        OutlineSchema, QuerySchema, RequestSchema, ScopeQuerySchema, ScopeRequestSchema,
49        SearchSchema, TldrCacheUpdateSchema,
50    };
51
52    #[test]
53    fn native_api_version_is_explicit() {
54        assert_eq!(NATIVE_API_VERSION, "0.11");
55        assert_eq!(CLI_PROTOCOL_VERSION, "mant.cli/v0.11");
56    }
57
58    #[test]
59    fn advertised_schema_ids_match_their_serialized_markers() {
60        for (value, expected) in [
61            (
62                serde_json::to_value(RequestSchema::V0Dot11),
63                RequestSchema::ID,
64            ),
65            (serde_json::to_value(QuerySchema::V0Dot11), QuerySchema::ID),
66            (
67                serde_json::to_value(DocumentSchema::V0Dot11),
68                DocumentSchema::ID,
69            ),
70            (
71                serde_json::to_value(OutlineSchema::V0Dot11),
72                OutlineSchema::ID,
73            ),
74            (
75                serde_json::to_value(ExcerptSchema::V0Dot11),
76                ExcerptSchema::ID,
77            ),
78            (
79                serde_json::to_value(SearchSchema::V0Dot11),
80                SearchSchema::ID,
81            ),
82            (
83                serde_json::to_value(ScopeRequestSchema::V0Dot11),
84                ScopeRequestSchema::ID,
85            ),
86            (
87                serde_json::to_value(ScopeQuerySchema::V0Dot11),
88                ScopeQuerySchema::ID,
89            ),
90            (
91                serde_json::to_value(CatalogSchema::V0Dot11),
92                CatalogSchema::ID,
93            ),
94            (
95                serde_json::to_value(TldrCacheUpdateSchema::V1),
96                TldrCacheUpdateSchema::ID,
97            ),
98        ] {
99            assert_eq!(value.expect("serialize schema marker"), expected);
100        }
101    }
102}