Skip to main content

AdminPageHandler

Trait AdminPageHandler 

Source
pub trait AdminPageHandler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn slug(&self) -> &'static str;
    fn label(&self) -> &'static str;
    fn render<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: AdminPageCtx<'life1>,
    ) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn icon(&self) -> Option<&'static str> { ... }
    fn section(&self) -> SidebarSection { ... }
    fn sort_order(&self) -> i32 { ... }
    fn permission_resource(&self) -> Option<&'static str> { ... }
}
Expand description

Trait every custom admin page implements. Compiled-in via the inventory registry — see crate::register_admin_page!.

Required Methods§

Source

fn slug(&self) -> &'static str

URL slug. The page mounts at /cms-admin/x/<slug>. Must stay stable; bookmarks / links reference this value.

Source

fn label(&self) -> &'static str

Visible label rendered in the sidebar.

Source

fn render<'life0, 'life1, 'async_trait>( &'life0 self, ctx: AdminPageCtx<'life1>, ) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Render the page. The implementation owns its template + form dispatch (handlers usually render via Tera with the bundled chrome by extending rcms_admin/_base.html).

Provided Methods§

Source

fn icon(&self) -> Option<&'static str>

Optional Material-symbols icon name (e.g. "insights", "bug_report").

Source

fn section(&self) -> SidebarSection

Which sidebar section the entry lives under. Defaults to a generic Custom("Tools") bucket so out-of-the-box behaviour keeps third-party pages visually separated from built-ins.

Source

fn sort_order(&self) -> i32

Sibling order within the section (ascending). Defaults to 100 so most third-party pages slot in between built-ins (which use lower numbers) without needing to think about ordering.

Source

fn permission_resource(&self) -> Option<&'static str>

Codename prefix to surface this page in the role permissions matrix. Returning Some("acme_reports") adds a “Custom admin pages → <label>” row with view + edit columns, granting / revoking codenames acme_reports.view and acme_reports.edit. Default None means the page is not access-controlled by the matrix — hosts can still gate inside render() manually.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§