mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-05-19 10:16:59 +02:00
docs(config): encode defaults of unwrapped options into schema
This commit ensures that the various default values that the different Option<T> config properties can be unwrapped to are encoded by schemars so that they can be picked up by docgen.
This commit is contained in:
@@ -14,12 +14,17 @@ use std::process::Command;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
|
||||
mod defaults {
|
||||
pub const DATA_REFRESH_INTERVAL: u64 = 12;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub struct UpdateConfig {
|
||||
/// Enable the Update widget
|
||||
pub enable: bool,
|
||||
/// Data refresh interval (default: 12 hours)
|
||||
/// Data refresh interval in hours
|
||||
#[cfg_attr(feature = "schemars", schemars(extend("default" = defaults::DATA_REFRESH_INTERVAL)))]
|
||||
pub data_refresh_interval: Option<u64>,
|
||||
/// Display label prefix
|
||||
pub label_prefix: Option<LabelPrefix>,
|
||||
@@ -27,7 +32,9 @@ pub struct UpdateConfig {
|
||||
|
||||
impl From<UpdateConfig> for Update {
|
||||
fn from(value: UpdateConfig) -> Self {
|
||||
let data_refresh_interval = value.data_refresh_interval.unwrap_or(12);
|
||||
let data_refresh_interval = value
|
||||
.data_refresh_interval
|
||||
.unwrap_or(defaults::DATA_REFRESH_INTERVAL);
|
||||
|
||||
let mut latest_version = String::new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user