Skip to main content

RouterBuilderPanelExt

Trait RouterBuilderPanelExt 

Source
pub trait RouterBuilderPanelExt: Sized {
    // Required methods
    fn panel(self, panel: Panel) -> Result<Self>;
    fn panel_handle(&self, prefix: &str) -> Option<PanelHandle>;
}
Expand description

Mounts a Panel on a router the app owns.

let router = Router::builder()
    .discover()
    .with(db)
    .panel(Panel::new("admin").resource::<UserResource>())?
    .panel(Panel::new("portal").auth(Auth::custom(Members)).resource::<OrderResource>())?
    .build();

Required Methods§

Source

fn panel(self, panel: Panel) -> Result<Self>

Mounts panel at its prefix with its routes, shell layout, and gating layers.

The panel reads the router’s Db and asset bundle, so .with(db) and .assets(..) come first. The first panel mounted also installs what every panel shares: cookies, the gate over Topcoat’s runtime endpoints, and Topcoat’s runtime layer with link prefetching off unless the router already set those up. A panel keeps its sessions in its own cookie, so the app’s Topcoat sessions, if any, stay the app’s. The runtime layer has no path, so mount panels after the app’s own pathless layers: a page re-run must reach those layers already rewritten to a GET.

§Errors

A MountError listing every declaration mistake, each a DeclarationErrorKind.

Source

fn panel_handle(&self, prefix: &str) -> Option<PanelHandle>

The panel mounted at prefix, for code that runs outside a request; None when no panel is mounted there. prefix is spelled as for Panel::new: "admin" and "/admin/" name the same panel.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl RouterBuilderPanelExt for RouterBuilder

Source§

fn panel(self, panel: Panel) -> Result<Self>

Source§

fn panel_handle(&self, prefix: &str) -> Option<PanelHandle>

Implementors§