|
@@ -1454,7 +1454,7 @@ impl<'de> Deserialize<'de> for UpdaterEndpoint {
|
|
|
|
|
|
/// The Updater configuration object.
|
|
/// The Updater configuration object.
|
|
#[skip_serializing_none]
|
|
#[skip_serializing_none]
|
|
-#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
|
|
|
|
|
|
+#[derive(Debug, PartialEq, Clone, Serialize)]
|
|
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
|
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
|
pub struct UpdaterConfig {
|
|
pub struct UpdaterConfig {
|
|
@@ -1470,6 +1470,38 @@ pub struct UpdaterConfig {
|
|
pub pubkey: String,
|
|
pub pubkey: String,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+impl<'de> Deserialize<'de> for UpdaterConfig {
|
|
|
|
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
|
|
+ where
|
|
|
|
+ D: Deserializer<'de>,
|
|
|
|
+ {
|
|
|
|
+ #[derive(Deserialize)]
|
|
|
|
+ struct InnerUpdaterConfig {
|
|
|
|
+ #[serde(default)]
|
|
|
|
+ active: bool,
|
|
|
|
+ #[serde(default = "default_dialog")]
|
|
|
|
+ dialog: bool,
|
|
|
|
+ endpoints: Option<Vec<UpdaterEndpoint>>,
|
|
|
|
+ pubkey: Option<String>,
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let config = InnerUpdaterConfig::deserialize(deserializer)?;
|
|
|
|
+
|
|
|
|
+ if config.active && config.pubkey.is_none() {
|
|
|
|
+ return Err(DeError::custom(
|
|
|
|
+ "The updater `pubkey` configuration is required.",
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Ok(UpdaterConfig {
|
|
|
|
+ active: config.active,
|
|
|
|
+ dialog: config.dialog,
|
|
|
|
+ endpoints: config.endpoints,
|
|
|
|
+ pubkey: config.pubkey.unwrap_or_else(String::new),
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
impl Default for UpdaterConfig {
|
|
impl Default for UpdaterConfig {
|
|
fn default() -> Self {
|
|
fn default() -> Self {
|
|
Self {
|
|
Self {
|