From 9bc945f76fa18849b8b874ce5c567dc516c53a49 Mon Sep 17 00:00:00 2001 From: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Date: Wed, 7 May 2025 09:33:26 -0600 Subject: [PATCH] upcast v0 action results to v1 (#2930) --- core/startos/src/action.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/startos/src/action.rs b/core/startos/src/action.rs index b29768d73..891296e34 100644 --- a/core/startos/src/action.rs +++ b/core/startos/src/action.rs @@ -83,6 +83,28 @@ pub enum ActionResult { #[serde(rename = "1")] V1(ActionResultV1), } +impl ActionResult { + pub fn upcast(self) -> Self { + match self { + Self::V0(ActionResultV0 { + message, + value, + copyable, + qr, + }) => Self::V1(ActionResultV1 { + title: "Action Complete".into(), + message: Some(message), + result: value.map(|value| ActionResultValue::Single { + value, + copyable, + qr, + masked: false, + }), + }), + Self::V1(a) => Self::V1(a), + } + } +} impl fmt::Display for ActionResult { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -308,4 +330,5 @@ pub async fn run_action( .or_not_found(lazy_format!("Manager for {}", package_id))? .run_action(Guid::new(), action_id, input.unwrap_or_default()) .await + .map(|res| res.map(ActionResult::upcast)) }