Skip to main content

mochi_protocol/
contributions.rs

1//! What modules offer each other: a page for the control center, a card on its
2//! home screen. A module declares them up front; the module they're meant for
3//! finds them, and they're simply unused when it isn't enabled.
4
5use serde::{Deserialize, Serialize};
6use serde_json::Value;
7
8/// One thing a module offers another.
9#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10pub struct Contribution {
11    /// The module offering it, whose view it is.
12    pub module: String,
13    /// The module it's for, like `control-center`.
14    pub target: String,
15    /// What it is to the target, like `page` or `card`. The target decides
16    /// which kinds it takes.
17    pub kind: String,
18    /// Unique within the offering module.
19    pub id: String,
20    /// `modules/<module>/<view>.qml`. It gets the offering module's
21    /// published state as `payload`. Empty for what has no view, like a
22    /// launcher provider.
23    #[serde(default)]
24    pub view: String,
25    pub title: String,
26    /// An icon name from the icon theme, or a path.
27    #[serde(default, skip_serializing_if = "Option::is_none")]
28    pub icon: Option<String>,
29    /// Lower comes first.
30    #[serde(default)]
31    pub order: i32,
32    /// Anything else the target reads, like a card's width.
33    #[serde(default, skip_serializing_if = "Value::is_null")]
34    pub options: Value,
35}