From 93ac5d1008030ccd587dad72cc3d42fd9eaf2bdf Mon Sep 17 00:00:00 2001 From: pml68 Date: Sat, 26 Oct 2024 21:54:49 +0200 Subject: refactor: rename `ActionKind` to `Action` --- iced_builder/src/types/element_name.rs | 12 ++++++------ iced_builder/src/types/rendered_element.rs | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'iced_builder/src/types') diff --git a/iced_builder/src/types/element_name.rs b/iced_builder/src/types/element_name.rs index 8d00814..93e12a1 100644 --- a/iced_builder/src/types/element_name.rs +++ b/iced_builder/src/types/element_name.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::Error; use super::rendered_element::{ - button, column, container, image, row, svg, text, ActionKind, RenderedElement, + button, column, container, image, row, svg, text, Action, RenderedElement, }; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -31,7 +31,7 @@ impl ElementName { pub fn handle_action( &self, element_tree: Option<&mut RenderedElement>, - action: ActionKind, + action: Action, ) -> Result, Error> { let element = match self { Self::Text(_) => text(""), @@ -43,9 +43,9 @@ impl ElementName { Self::Column => column(None), }; match action { - ActionKind::Stop => Ok(None), - ActionKind::AddNew => Ok(Some(element)), - ActionKind::PushFront(id) => { + Action::Stop => Ok(None), + Action::AddNew => Ok(Some(element)), + Action::PushFront(id) => { element_tree .ok_or("The action was of kind `PushFront`, but no element tree was provided.")? .find_by_id(id) @@ -53,7 +53,7 @@ impl ElementName { .push_front(&element); Ok(None) } - ActionKind::InsertAfter(parent_id, child_id) => { + Action::InsertAfter(parent_id, child_id) => { element_tree .ok_or( "The action was of kind `InsertAfter`, but no element tree was provided.", diff --git a/iced_builder/src/types/rendered_element.rs b/iced_builder/src/types/rendered_element.rs index 50e591a..08d7ba3 100755 --- a/iced_builder/src/types/rendered_element.rs +++ b/iced_builder/src/types/rendered_element.rs @@ -120,16 +120,16 @@ impl RenderedElement { pub fn handle_action( &self, element_tree: Option<&mut RenderedElement>, - action: ActionKind, + action: Action, ) -> Result<(), Error> { let element_tree = element_tree.unwrap(); match action { - ActionKind::Stop => Ok(()), - ActionKind::AddNew => Err( + Action::Stop => Ok(()), + Action::AddNew => Err( "the action was of kind `AddNew`, but invoking it on an existing element tree is not possible".into(), ), - ActionKind::PushFront(id) => { + Action::PushFront(id) => { let old_parent = element_tree.find_parent(self).unwrap(); old_parent.remove(self); @@ -138,7 +138,7 @@ impl RenderedElement { Ok(()) } - ActionKind::InsertAfter(parent_id, target_id) => { + Action::InsertAfter(parent_id, target_id) => { let old_parent = element_tree.find_parent(self).unwrap(); old_parent.remove(self); @@ -300,14 +300,14 @@ impl std::fmt::Display for RenderedElement { } #[derive(Debug, Clone)] -pub enum ActionKind { +pub enum Action { AddNew, PushFront(Id), InsertAfter(Id, Id), Stop, } -impl ActionKind { +impl Action { pub fn new( ids: Vec, element_tree: &mut Option, -- cgit v1.2.3