1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! This module contains auxiliary definitions for generating JSONSchemas.
//! See <https://graham.cool/schemars/examples/5-remote_derive/>.
#![allow(dead_code)]
use schemars::JsonSchema;
pub(crate) mod log {
use super::*;
/// See [`::log::Level`]
#[derive(JsonSchema)]
#[schemars(
remote = "log::Level",
description = "A log level.",
rename_all = "UPPERCASE"
)]
pub(crate) enum Level {
/// Designates very serious errors.
Error,
/// Designates hazardous situations.
Warn,
/// Designates useful information.
Info,
/// Designates lower priority information.
Debug,
/// Designates very low priority, often extremely verbose, information.
Trace,
}
}
pub(crate) mod bytesize {
use super::*;
/// See [`::bytesize::ByteSize`] as well as [`::bytesize::parse`].
/// Note that the pattern here is a little more restrictive than
/// the actual parsing logic, as it enforces particular casing and whitespace.
/// However, the regular expression is easier to read.
#[derive(JsonSchema)]
#[schemars(
remote = "bytesize::ByteSize",
description = "Byte quantities using unit prefixes according to SI or ISO/IEC 80000-13.",
extend("examples" = ["7 G", "50.3 TiB", "200 B", "4 Ki", "10 MB"]),
)]
pub(crate) struct ByteSize(
#[schemars(regex(pattern = r"^\d+(\.\d+)? ((K|M|G|T|P)i?B?|B)$"))] String,
);
}
pub(crate) mod git {
pub(crate) mod fmt {
/// See [`crate::git::fmt::RefString`]
#[derive(schemars::JsonSchema)]
pub(crate) struct RefString(String);
}
}