Skip to content

Commit

Permalink
new: Add unstable setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jan 17, 2025
1 parent 97a4f84 commit 79b9476
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/pdk-api/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod build_source;

use crate::shapes::StringOrVec;
use crate::shapes::*;
use rustc_hash::FxHashMap;
use std::path::PathBuf;
use version_spec::{CalVer, SemVer, SpecError, UnresolvedVersionSpec, VersionSpec};
Expand Down Expand Up @@ -109,6 +109,9 @@ api_struct!(
/// Type of the tool.
#[serde(rename = "type")]
pub type_of: PluginType,

/// Whether this plugin is unstable or not.
pub unstable: Switch,
}
);

Expand Down
24 changes: 24 additions & 0 deletions crates/pdk-api/src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,27 @@ impl StringOrVec {
}
}
}

api_enum!(
/// Either a boolean representing on or off, or a string representing on with a message.
#[serde(untagged)]
pub enum Switch {
Toggle(bool),
Message(String),
}
);

impl Default for Switch {
fn default() -> Self {
Self::Toggle(false)
}
}

impl Switch {
pub fn is_enabled(&self) -> bool {
match self {
Self::Toggle(value) => *value,
Self::Message(_) => true,
}
}
}

0 comments on commit 79b9476

Please sign in to comment.