settings: Remove auxiliary Content types where possible (#16744)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-10 22:59:10 -04:00 committed by GitHub
parent 8f28445612
commit ccf6f27b8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 843 additions and 696 deletions

View file

@ -99,20 +99,26 @@ pub const CONNECTION_TIMEOUT: Duration = Duration::from_secs(20);
actions!(client, [SignIn, SignOut, Reconnect]);
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
pub struct ClientSettingsContent {
server_url: Option<String>,
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct ClientSettings {
/// The server to connect to. If the environment variable
/// ZED_SERVER_URL is set, it will override this setting.
pub server_url: String,
}
#[derive(Deserialize)]
pub struct ClientSettings {
pub server_url: String,
impl Default for ClientSettings {
fn default() -> Self {
Self {
server_url: "https://zed.dev".to_owned(),
}
}
}
impl Settings for ClientSettings {
const KEY: Option<&'static str> = None;
type FileContent = ClientSettingsContent;
type FileContent = Self;
fn load(sources: SettingsSources<Self::FileContent>, _: &mut AppContext) -> Result<Self> {
let mut result = sources.json_merge::<Self>()?;
@ -124,19 +130,37 @@ impl Settings for ClientSettings {
}
#[derive(Default, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ProxySettingsContent {
proxy: Option<String>,
#[serde(default)]
pub struct ProxySettings {
/// Set a proxy to use. The proxy protocol is specified by the URI scheme.
///
/// Supported URI scheme: `http`, `https`, `socks4`, `socks4a`, `socks5`,
/// `socks5h`. `http` will be used when no scheme is specified.
///
/// By default no proxy will be used, or Zed will try get proxy settings from
/// environment variables.
///
/// Examples:
/// - "proxy": "socks5://localhost:10808"
/// - "proxy": "http://127.0.0.1:10809"
#[schemars(example = "Self::example_1")]
#[schemars(example = "Self::example_2")]
pub proxy: Option<String>,
}
#[derive(Deserialize, Default)]
pub struct ProxySettings {
pub proxy: Option<String>,
impl ProxySettings {
fn example_1() -> String {
"http://127.0.0.1:10809".to_owned()
}
fn example_2() -> String {
"socks5://localhost:10808".to_owned()
}
}
impl Settings for ProxySettings {
const KEY: Option<&'static str> = None;
type FileContent = ProxySettingsContent;
type FileContent = Self;
fn load(sources: SettingsSources<Self::FileContent>, _: &mut AppContext) -> Result<Self> {
Ok(Self {