From 83172c7bc584283d7dd4b93f3f18ec0f2d9a1ad0 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Wed, 28 Aug 2024 12:49:23 +0100 Subject: [PATCH] gui(installer): add general node definition --- gui/src/installer/step/node/mod.rs | 51 ++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/gui/src/installer/step/node/mod.rs b/gui/src/installer/step/node/mod.rs index 22480050..f63f1004 100644 --- a/gui/src/installer/step/node/mod.rs +++ b/gui/src/installer/step/node/mod.rs @@ -13,15 +13,62 @@ use crate::{ use iced::Command; use liana_ui::widget::Element; +#[derive(Clone)] +pub enum NodeDefinition { + Bitcoind(DefineBitcoind), +} + +impl NodeDefinition { + fn new() -> Self { + NodeDefinition::Bitcoind(DefineBitcoind::new()) + } + + fn apply(&mut self, ctx: &mut Context) -> bool { + match self { + NodeDefinition::Bitcoind(def) => def.apply(ctx), + } + } + + fn can_try_ping(&self) -> bool { + match self { + NodeDefinition::Bitcoind(def) => def.can_try_ping(), + } + } + + fn load_context(&mut self, ctx: &Context) { + match self { + NodeDefinition::Bitcoind(def) => def.load_context(ctx), + } + } + + fn update(&mut self, message: message::DefineNode) -> Command { + match self { + NodeDefinition::Bitcoind(def) => def.update(message), + } + } + + fn view(&self) -> Element { + match self { + NodeDefinition::Bitcoind(def) => def.view(), + } + } + + fn ping(&self) -> Result<(), Error> { + match self { + NodeDefinition::Bitcoind(def) => def.ping(), + } + } +} + pub struct Node { - definition: DefineBitcoind, + definition: NodeDefinition, is_running: Option>, } impl Node { fn new() -> Self { Node { - definition: DefineBitcoind::new(), + definition: NodeDefinition::new(), is_running: None, } }