From 71c1305fca75355f9a4bcacc588baa672e5380d6 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Sun, 4 Jun 2023 09:28:39 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Handle=20por=20defecto=20para=20def?= =?UTF-8?q?iniciones=20del=20core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagetop/src/core/component/definition.rs | 4 ++-- pagetop/src/core/hook/definition.rs | 8 ++++++-- pagetop/src/core/module/definition.rs | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pagetop/src/core/component/definition.rs b/pagetop/src/core/component/definition.rs index db683062..bc03b30d 100644 --- a/pagetop/src/core/component/definition.rs +++ b/pagetop/src/core/component/definition.rs @@ -5,7 +5,7 @@ use crate::{define_handle, Handle}; pub use std::any::Any as AnyComponent; -define_handle!(COMPONENT_UNDEFINED); +define_handle!(COMPONENT_UNNAMED); pub trait BaseComponent { fn render(&mut self, rcx: &mut RenderContext) -> Markup; @@ -17,7 +17,7 @@ pub trait ComponentTrait: AnyComponent + BaseComponent + Send + Sync { Self: Sized; fn handle(&self) -> Handle { - COMPONENT_UNDEFINED + COMPONENT_UNNAMED } fn name(&self) -> String { diff --git a/pagetop/src/core/hook/definition.rs b/pagetop/src/core/hook/definition.rs index 047bab6d..49b82d52 100644 --- a/pagetop/src/core/hook/definition.rs +++ b/pagetop/src/core/hook/definition.rs @@ -1,13 +1,17 @@ -use crate::Handle; +use crate::{define_handle, Handle}; pub use std::any::Any as AnyHookAction; +define_handle!(HOOK_UNNAMED); + pub trait HookActionTrait: AnyHookAction + Send + Sync { fn new() -> Self where Self: Sized; - fn handle(&self) -> Handle; + fn handle(&self) -> Handle { + HOOK_UNNAMED + } fn weight(&self) -> isize { 0 diff --git a/pagetop/src/core/module/definition.rs b/pagetop/src/core/module/definition.rs index d4350c3b..71197055 100644 --- a/pagetop/src/core/module/definition.rs +++ b/pagetop/src/core/module/definition.rs @@ -3,20 +3,24 @@ use super::ThemeStaticRef; use crate::core::component::L10n; use crate::core::hook::HookAction; use crate::util::single_type_name; -use crate::{server, Handle}; +use crate::{define_handle, server, Handle}; #[cfg(feature = "database")] use crate::db::MigrationItem; pub type ModuleStaticRef = &'static dyn ModuleTrait; +define_handle!(APP_UNNAMED); + pub trait BaseModule { fn single_name(&self) -> &'static str; } /// Los módulos deben implementar este *trait*. pub trait ModuleTrait: BaseModule + Send + Sync { - fn handle(&self) -> Handle; + fn handle(&self) -> Handle { + APP_UNNAMED + } fn name(&self) -> L10n { L10n::text(self.single_name())