Skip to main content

mant_protocol/
lib.rs

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