Skip to main content

StatsOverviewWidget

Trait StatsOverviewWidget 

Source
pub trait StatsOverviewWidget:
    Send
    + Sync
    + 'static {
    // Required method
    fn stats<'a>(
        &'a self,
        db: &'a Database,
        user: &'a ActingUser,
    ) -> RuntimeFuture<'a, Vec<Stat>>;

    // Provided method
    fn can_view(&self, user: &ActingUser) -> bool { ... }
}
Expand description

A widget of the panel’s own on the dashboard, as Filament’s StatsOverviewWidget with its getStats(): the cards it computes for the signed-in user. Pass it to Ignite::widget.

ⓘ
struct SiteStats;

impl StatsOverviewWidget for SiteStats {
    fn stats<'a>(&'a self, db: &'a Database, _: &'a ActingUser) -> RuntimeFuture<'a, Vec<Stat>> {
        Box::pin(async move {
            let comments = count_pending_comments(db).await?;
            Ok(vec![Stat::make("Comments", comments).description("awaiting moderation")])
        })
    }
}

Required Methods§

Source

fn stats<'a>( &'a self, db: &'a Database, user: &'a ActingUser, ) -> RuntimeFuture<'a, Vec<Stat>>

The cards, in display order, for user.

Provided Methods§

Source

fn can_view(&self, user: &ActingUser) -> bool

Whether user sees the widget, as Filament’s canView(). The default is every user.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§