kernel/common/
schema_path.rs1use nutype::nutype;
2use std::path::PathBuf;
3
4#[nutype(derive(
5 Debug,
6 Clone,
7 AsRef,
8 Deref,
9 Hash,
10 Eq,
11 PartialEq,
12 Serialize,
13 Deserialize
14))]
15pub struct SchemaPath(PathBuf);
16
17impl AsRef<std::path::Path> for SchemaPath {
18 fn as_ref(&self) -> &std::path::Path {
19 self.as_path()
20 }
21}
22
23impl schemars::JsonSchema for SchemaPath {
25 fn schema_name() -> std::borrow::Cow<'static, str> {
26 std::borrow::Cow::Borrowed("SchemaPath")
27 }
28
29 fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
30 schemars::json_schema!({
31 "type": "string",
32 "format": "uri-reference",
33 "pattern": "^[^/][^:]*\\.ya?ml$",
34 "description": "Path to the index schema YAML file, resolved relative to the config file's directory."
35 })
36 }
37}