pub struct AppComponents<'a> {
pub pages: Option<UserPages<'a>>,
pub components: Option<UserComponents<'a>>,
pub forms: Option<Forms<'a>>,
pub apis: Option<UserAPIEndpoints<'a>>,
}Expand description
Struct encapsulating custom-made items to register with the framework.
§Pages
The pages field accepts an optional of UserPages which is a vector of PageItem.
vec![
("my_page", my_page_function),
...
];The page function is of type PageFunction.
It is important to understand that a page is a function that simply list the series of components to be rendered.
We rely on CSS for the actual layout in 2D space. Therefore, a page function should not prescribe the page layout per se.
§Components
The components field takes an optional of UserComponents which is a vector of UserComponentItem.
vec![
("my_component", my_component_function),
...
];The component function is of type PageFunction.
§Forms
The forms field takes an optional of Forms which is a vector of FormItem.
vec![
("my_form", my_form_function),
...
];The form function is of type FormBuilderFunction.
Although a form is treated as a type of component in the framework, its implementation and behavior is closer to
a page in that its main role is to define the vector of FormElementBuilder.
These element builder functions further renders the actual form component to be inserted in linear order. Again, these functions
say nothing about the layout of the form as that is handled via CSS.
§APIs
The apis field takes an optional of UserAPIEndpoints which is a vector of APIItem.
vec![
("/my/api/endpoint", my_api_handler),
...
];The api function is of type APIFunction.
These API functions are your handlers directly mapped to the REST route you wish to intercept. This enables a simple key-value pair approach to defining API endpoints in your web app. These handlers can queue asynchronous pipeline jobs, return HTML fragments, redirect the current page somewhere else, or a combination of these. It is a powerful interface for organizing your routing.
Fields§
§pages: Option<UserPages<'a>>§components: Option<UserComponents<'a>>§forms: Option<Forms<'a>>§apis: Option<UserAPIEndpoints<'a>>