Skip to main content

wire/answer/
known_hosts.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! The vendors this city knows by host, as the settings page offers
7//! them (`crates/wire/spec/Answer/KnownHosts.lean` ยง8-51).
8//!
9//! A person picks a vendor rather than copying its address out of the
10//! vendor's documentation. The table is `gateway::provider::preset`'s;
11//! this shape only carries it, and the page decides which faces it
12//! offers from the same answer rather than from a table of its own.
13
14use kernel::DialectKind;
15use serde::{Deserialize, Serialize};
16
17/// Every host the city knows, in the table's own order.
18#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
19#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
20pub struct KnownHostsAnswer {
21    pub hosts: Vec<KnownHost>,
22}
23
24/// One vendor's host, and the faces it documents, main face first.
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
27pub struct KnownHost {
28    pub host: String,
29    pub faces: Vec<KnownFace>,
30}
31
32/// One face and the base URL it is called at: the URL attaching this
33/// face would store, so a form that fills it in changes nothing when
34/// the city normalises it.
35#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
36#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
37pub struct KnownFace {
38    pub dialect: DialectKind,
39    pub base_url: String,
40}