Skip to main content

Page

Trait Page 

Source
pub trait Page:
    Sized
    + Send
    + Sync
    + 'static {
    // Required method
    fn render(cx: &Cx) -> impl Future<Output = Result<impl View>> + Send;

    // Provided methods
    fn slug() -> String { ... }
    fn navigation_label() -> String { ... }
    fn navigation() -> NavigationItem { ... }
}
Expand description

A panel page that is not a resource, mounted at {prefix}/{slug} with a sidebar entry; the panel owns the route and entry while the page owns its markup.

struct ReportsPage;

impl Page for ReportsPage {
    async fn render(cx: &Cx) -> Result<impl View> {
        Ok(view! { cx => tablo_ui::page(tablo_ui::page_title("Reports")) })
    }
}

Panel::new("admin").page::<ReportsPage>() // GET /admin/reports

A page serves one GET with a sidebar entry; a form it renders posts to an app-declared route the auth gate covers.

Required Methods§

Source

fn render(cx: &Cx) -> impl Future<Output = Result<impl View>> + Send

Render the page body. The panel checks for a resolved user before calling it.

Provided Methods§

Source

fn slug() -> String

The URL segment under the panel prefix. Default: the type name without a Page suffix, kebab-cased (MediaLibraryPage → media-library).

Panel::home mounts the page at the prefix and does not read it.

Source

fn navigation_label() -> String

The sidebar label. Default: the type name without a Page suffix, in sentence case (MediaLibraryPage → Media library).

Source

fn navigation() -> NavigationItem

The sidebar entry; override to set the order or the icon.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§