// Copyright 2019-2023 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT use serde::{Deserialize, Deserializer}; use url::Url; /// Updater configuration. #[derive(Debug, Clone, Deserialize)] pub struct Config { #[serde(default)] pub endpoints: Vec, /// Additional arguments given to the NSIS or WiX installer. #[serde(default, alias = "installer-args")] pub installer_args: Vec, } /// A URL to an updater server. /// /// The URL must use the `https` scheme on production. #[derive(Debug, PartialEq, Eq, Clone)] pub struct UpdaterEndpoint(pub Url); impl std::fmt::Display for UpdaterEndpoint { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) } } impl<'de> Deserialize<'de> for UpdaterEndpoint { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let url = Url::deserialize(deserializer)?; #[cfg(all(not(debug_assertions), not(feature = "schema")))] { if url.scheme() != "https" { return Err(serde::de::Error::custom( "The configured updater endpoint must use the `https` protocol.", )); } } Ok(Self(url)) } }