mas_config/
schema.rs

1// Copyright 2024 New Vector Ltd.
2// Copyright 2022-2024 The Matrix.org Foundation C.I.C.
3//
4// SPDX-License-Identifier: AGPL-3.0-only
5// Please see LICENSE in the repository root for full details.
6
7//! Useful JSON Schema definitions
8
9use schemars::{
10    JsonSchema,
11    r#gen::SchemaGenerator,
12    schema::{InstanceType, Schema, SchemaObject},
13};
14
15/// A network hostname
16pub struct Hostname;
17
18impl JsonSchema for Hostname {
19    fn schema_name() -> String {
20        "Hostname".to_string()
21    }
22
23    fn json_schema(generator: &mut SchemaGenerator) -> Schema {
24        hostname(generator)
25    }
26}
27
28fn hostname(_gen: &mut SchemaGenerator) -> Schema {
29    Schema::Object(SchemaObject {
30        instance_type: Some(InstanceType::String.into()),
31        format: Some("hostname".to_owned()),
32        ..SchemaObject::default()
33    })
34}