Skip to main content

Banner

Trait Banner 

Source
pub trait Banner:
    Send
    + Sync
    + 'static {
    // Required method
    fn render(
        cx: &Cx,
    ) -> impl Future<Output = Result<Option<impl View>, Error>> + Send;
}
Expand description

A strip above every page of a panel, under the bar that names whom a user acts as, installed with Panel::banner: what the signed-in user must see wherever they are, such as a failed payment or an expiring trial.

use tablo_core::{Banner, Panel, auth};
use topcoat::{
    Result,
    context::Cx,
    view::{View, view},
};

struct PaymentFailed;

impl Banner for PaymentFailed {
    async fn render(cx: &Cx) -> Result<Option<impl View>> {
        // A real banner reads the signed-in user's billing state here.
        let failed = auth::signed_in(cx) && false;
        Ok(failed.then(|| view! { <div role="alert">"Your last payment failed."</div> }))
    }
}

Panel::new("app").banner::<PaymentFailed>();

Required Methods§

Source

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

The strip for this request, or None to show nothing. It is asked on every page the panel’s shell frames, signed in or not, and an error fails the page.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§