Trait libhealth::plugins::Plugin

source ·
pub trait Plugin: DynClone + Debug {
    // Required methods
    fn details(&self, mocked: bool) -> PluginDetails;
    fn name(&self) -> PluginName;
    fn icon_name(&self) -> &'static str;
    fn localised_name(&self) -> String;

    // Provided methods
    fn summary(&self) -> PluginSummaryRow { ... }
    fn overview(&self) -> PluginOverviewRow { ... }
}
Expand description

The Plugin trait should be implemented for additional data sources of Health.

The trait automatically provides an implementation of Plugin::overview(), returning a PluginOverviewRow containing the localised name and the icon of the plugin. The user may click on this row to access the (mocked) PluginDetails page to see what the plugin does and to enable it. Once the plugin is enabled, the PluginSummaryRow returned by Plugin::summary() is shown to the user in the list of enabled plugins, giving the user a quick glance over the data (e.g. “Today you’ve done X of Y steps”). Upon clicking this PluginSummaryRow, the user is taken to the (unmocked) PluginDetails page.

To create a new plugin, you should do the following things:

  1. Create a new subfolder in src/plugins/$plugin_name
  2. Create a details.rs and summary.rs, containing the subclass of PluginDetails and PluginSummaryRow respectively.
  3. Add the name of your plugin to PluginName (and fix compile errors from non-exhaustive match arms).
  4. Create a plugin.rs and implement the Plugin trait.
  5. Finally, add your plugin to the list in the Registrar

Required Methods§

source

fn details(&self, mocked: bool) -> PluginDetails

Returns a card view containing details,e.g. steps over some weeks. May be mocked via the is-mocked property.

source

fn name(&self) -> PluginName

The non-localised name of the plugin, used as ID. !Must! be unique across plugins

source

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

The name of the icon that should be used for the overview row

source

fn localised_name(&self) -> String

The localised name of the plugin, that’s displayed to the user.

Provided Methods§

source

fn summary(&self) -> PluginSummaryRow

Returns a card view with a short overview of the data, e.g 2000/10000 steps done for the home page

source

fn overview(&self) -> PluginOverviewRow

Returns an entry for the “browse all” listbox.

Trait Implementations§

source§

impl<'clone> Clone for Box<dyn Plugin + 'clone>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn Plugin + Send + 'clone>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn Plugin + Send + Sync + 'clone>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn Plugin + Sync + 'clone>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§