Trait Module

Source
pub trait Module {
    // Required methods
    fn id(&self) -> &str;
    fn config(&self) -> &ModuleConfig;
    fn head_tags(&self) -> &Nodes;
    fn view(&self) -> Nodes;
    fn run(
        &mut self,
        runtime_info: Rc<RuntimeInformation>,
    ) -> Result<(), LewpError>;

    // Provided methods
    fn into_module_ptr(self) -> ModulePtr
       where Self: Sized + 'static { ... }
    fn render(&self) -> Nodes { ... }
}
Expand description

Defines a web page module.

Required Methods§

Source

fn id(&self) -> &str

Returns the unique module id.

Allowed characters for id are [a-z], [0-9] and -. There is currently no check wether other characters are used. So please make sure that you do not use any other characters while creating modules.

Source

fn config(&self) -> &ModuleConfig

The configuration of the module.

Source

fn head_tags(&self) -> &Nodes

Borrows the head tags that are required to run this module in a web page.

Source

fn view(&self) -> Nodes

Constructs the view of the module.

Source

fn run(&mut self, runtime_info: Rc<RuntimeInformation>) -> Result<(), LewpError>

Executes the module. Main function that is able to collect and modify data required for rendering.

Provided Methods§

Source

fn into_module_ptr(self) -> ModulePtr
where Self: Sized + 'static,

Wraps self into a Rc<RefCell<>>

Source

fn render(&self) -> Nodes

Renders as DOM nodes.

Implementors§