Skip to main content

AppComponents

Struct AppComponents 

Source
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>>

Trait Implementations§

Source§

impl<'a> Debug for AppComponents<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for AppComponents<'a>

Source§

fn default() -> AppComponents<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> PartialEq for AppComponents<'a>

Source§

fn eq(&self, other: &AppComponents<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for AppComponents<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for AppComponents<'a>

§

impl<'a> RefUnwindSafe for AppComponents<'a>

§

impl<'a> Send for AppComponents<'a>

§

impl<'a> Sync for AppComponents<'a>

§

impl<'a> Unpin for AppComponents<'a>

§

impl<'a> UnsafeUnpin for AppComponents<'a>

§

impl<'a> UnwindSafe for AppComponents<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Ungil for T
where T: Send,