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.8";
30
31/// Exact process protocol reported by the native CLI boundary.
32pub const CLI_PROTOCOL_VERSION: &str = "mant.cli/v0.8";
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,
40    };
41
42    #[test]
43    fn native_api_version_is_explicit() {
44        assert_eq!(NATIVE_API_VERSION, "0.8");
45        assert_eq!(CLI_PROTOCOL_VERSION, "mant.cli/v0.8");
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::V0Dot8),
53                RequestSchema::ID,
54            ),
55            (serde_json::to_value(QuerySchema::V0Dot8), QuerySchema::ID),
56            (
57                serde_json::to_value(DocumentSchema::V0Dot8),
58                DocumentSchema::ID,
59            ),
60            (
61                serde_json::to_value(OutlineSchema::V0Dot8),
62                OutlineSchema::ID,
63            ),
64            (
65                serde_json::to_value(ExcerptSchema::V0Dot8),
66                ExcerptSchema::ID,
67            ),
68            (serde_json::to_value(SearchSchema::V0Dot8), SearchSchema::ID),
69            (
70                serde_json::to_value(ScopeRequestSchema::V0Dot8),
71                ScopeRequestSchema::ID,
72            ),
73            (
74                serde_json::to_value(ScopeQuerySchema::V0Dot8),
75                ScopeQuerySchema::ID,
76            ),
77            (
78                serde_json::to_value(CatalogSchema::V0Dot8),
79                CatalogSchema::ID,
80            ),
81        ] {
82            assert_eq!(value.expect("serialize schema marker"), expected);
83        }
84    }
85}