🚧 Handles siempre requeridos en la implementación
This commit is contained in:
parent
0af85c4d77
commit
a48c575198
7 changed files with 16 additions and 24 deletions
|
|
@ -1,8 +1,14 @@
|
||||||
use pagetop::prelude::*;
|
use pagetop::prelude::*;
|
||||||
|
|
||||||
|
define_handle!(APP_HELLO_WORLD);
|
||||||
|
|
||||||
struct HelloWorld;
|
struct HelloWorld;
|
||||||
|
|
||||||
impl ModuleTrait for HelloWorld {
|
impl ModuleTrait for HelloWorld {
|
||||||
|
fn handle(&self) -> Handle {
|
||||||
|
APP_HELLO_WORLD
|
||||||
|
}
|
||||||
|
|
||||||
fn configure_service(&self, cfg: &mut server::web::ServiceConfig) {
|
fn configure_service(&self, cfg: &mut server::web::ServiceConfig) {
|
||||||
cfg.route("/", server::web::get().to(hello_world));
|
cfg.route("/", server::web::get().to(hello_world));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
mod definition;
|
mod definition;
|
||||||
pub use definition::{action_ref, ActionTrait, AnyAction, ACTION_UNNAMED};
|
pub use definition::{action_ref, ActionTrait, AnyAction};
|
||||||
|
|
||||||
mod bundle;
|
mod bundle;
|
||||||
pub use bundle::Action;
|
pub use bundle::Action;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
use crate::{define_handle, Handle};
|
use crate::Handle;
|
||||||
|
|
||||||
pub use std::any::Any as AnyAction;
|
pub use std::any::Any as AnyAction;
|
||||||
|
|
||||||
define_handle!(ACTION_UNNAMED);
|
|
||||||
|
|
||||||
pub trait ActionTrait: AnyAction + Send + Sync {
|
pub trait ActionTrait: AnyAction + Send + Sync {
|
||||||
fn new() -> Self
|
fn new() -> Self
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
fn handle(&self) -> Handle;
|
||||||
ACTION_UNNAMED
|
|
||||||
}
|
|
||||||
|
|
||||||
fn weight(&self) -> isize {
|
fn weight(&self) -> isize {
|
||||||
0
|
0
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@ mod context;
|
||||||
pub use context::{ContextOp, RenderContext};
|
pub use context::{ContextOp, RenderContext};
|
||||||
|
|
||||||
mod definition;
|
mod definition;
|
||||||
pub use definition::{
|
pub use definition::{component_mut, component_ref, AnyComponent, BaseComponent, ComponentTrait};
|
||||||
component_mut, component_ref, AnyComponent, BaseComponent, ComponentTrait, COMPONENT_UNNAMED,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod one;
|
mod one;
|
||||||
pub use one::OneComponent;
|
pub use one::OneComponent;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
use crate::core::component::RenderContext;
|
use crate::core::component::RenderContext;
|
||||||
use crate::html::{html, Markup};
|
use crate::html::{html, Markup};
|
||||||
use crate::{define_handle, util, Handle};
|
use crate::{util, Handle};
|
||||||
|
|
||||||
pub use std::any::Any as AnyComponent;
|
pub use std::any::Any as AnyComponent;
|
||||||
|
|
||||||
define_handle!(COMPONENT_UNNAMED);
|
|
||||||
|
|
||||||
pub trait BaseComponent {
|
pub trait BaseComponent {
|
||||||
fn render(&mut self, rcx: &mut RenderContext) -> Markup;
|
fn render(&mut self, rcx: &mut RenderContext) -> Markup;
|
||||||
}
|
}
|
||||||
|
|
@ -15,9 +13,7 @@ pub trait ComponentTrait: AnyComponent + BaseComponent + Send + Sync {
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
fn handle(&self) -> Handle;
|
||||||
COMPONENT_UNNAMED
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
util::single_type_name::<Self>().to_owned()
|
util::single_type_name::<Self>().to_owned()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
mod definition;
|
mod definition;
|
||||||
pub use definition::{BaseModule, ModuleStaticRef, ModuleTrait, MODULE_UNNAMED};
|
pub use definition::{BaseModule, ModuleStaticRef, ModuleTrait};
|
||||||
|
|
||||||
pub(crate) mod all;
|
pub(crate) mod all;
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,20 @@
|
||||||
use crate::base::component::L10n;
|
use crate::base::component::L10n;
|
||||||
use crate::core::action::Action;
|
use crate::core::action::Action;
|
||||||
use crate::core::theme::ThemeStaticRef;
|
use crate::core::theme::ThemeStaticRef;
|
||||||
use crate::{define_handle, server, util, Handle};
|
use crate::{server, util, Handle};
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
use crate::db::MigrationItem;
|
use crate::db::MigrationItem;
|
||||||
|
|
||||||
pub type ModuleStaticRef = &'static dyn ModuleTrait;
|
pub type ModuleStaticRef = &'static dyn ModuleTrait;
|
||||||
|
|
||||||
define_handle!(MODULE_UNNAMED);
|
|
||||||
|
|
||||||
pub trait BaseModule {
|
pub trait BaseModule {
|
||||||
fn single_name(&self) -> &'static str;
|
fn single_name(&self) -> &'static str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Los módulos deben implementar este *trait*.
|
/// Los módulos deben implementar este *trait*.
|
||||||
pub trait ModuleTrait: BaseModule + Send + Sync {
|
pub trait ModuleTrait: BaseModule + Send + Sync {
|
||||||
fn handle(&self) -> Handle {
|
fn handle(&self) -> Handle;
|
||||||
MODULE_UNNAMED
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> L10n {
|
||||||
L10n::text(self.single_name())
|
L10n::text(self.single_name())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue