pub trait Page:
Sized
+ Send
+ Sync
+ 'static {
// Provided methods
fn declare() -> PageDef { ... }
fn render(cx: &Cx) -> impl Future<Output = Result<impl View, Error>> + Send { ... }
}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 {}
Panel::new("admin").page::<ReportsPage>(); // GET /admin/reportsA page serves one GET with a sidebar entry, which PageDef::access limits
to the users it admits. A form it renders posts to an app-declared route the
auth gate covers; that route asks can_open itself.
Provided Methods§
Sourcefn declare() -> PageDef
fn declare() -> PageDef
The page’s slug, sidebar entry, access and header actions. Defaults to
PageDef::new: every default.
Panel::page_with adjusts it for one panel.
Sourcefn render(cx: &Cx) -> impl Future<Output = Result<impl View, Error>> + Send
fn render(cx: &Cx) -> impl Future<Output = Result<impl View, Error>> + Send
Render the page body. The panel checks for a resolved user and
PageDef::access before calling it.
Defaults to the page its PageDef declares: the title and
description, the buttons of its
header_actions, and the grid of its
widgets. A page that renders more places those parts itself, through
header_action_buttons and widgets:
struct ReportsPage;
impl Page for ReportsPage {
async fn render(cx: &Cx) -> Result<impl View> {
Ok(view! {
tablo_ui::page(
tablo_ui::page_header(tablo_ui::page_title("Reports"))
tablo_ui::page_content((tablo_core::widgets::<Self>(cx)) "…")
)
})
}
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".