Skip to main content

firefly_types/
manuals.rs

1use alloc::string::String;
2use alloc::vec::Vec;
3use serde::{Deserialize, Serialize};
4
5use crate::Encode;
6
7#[derive(Serialize, Deserialize, Clone, Debug)]
8pub struct Manual {
9    pub pages: Vec<Page>,
10}
11
12impl Encode<'_> for Manual {}
13
14#[derive(Serialize, Deserialize, Clone, Debug)]
15pub struct Page {
16    /// The page name as appears in the Table of Contents.
17    pub title: String,
18    /// Show the page only when the given badge is unlocked.
19    pub badge: Option<u8>,
20    /// Show the page only when the given score is reached on the given board.
21    pub score: Option<(u8, i16)>,
22    /// Encoded color scheme.
23    ///
24    /// It's encoded the same way as in [Settings][crate::Settings].
25    pub theme: Option<u32>,
26    pub content: Vec<Block>,
27}
28
29#[derive(Serialize, Deserialize, Clone, Debug)]
30pub enum Block {
31    /// The biggest header after the page title.
32    H2(String),
33    /// The smallest header.
34    H3(String),
35    /// Paragraph.
36    P(Paragraph),
37    /// Ordered (numbered) list item.
38    Oli(Paragraph),
39    /// Unrdered list item.
40    Uli(Paragraph),
41    /// Link to another page.
42    A(u8),
43    /// Block image, centered.
44    Img(String),
45    /// Block quote.
46    Quote(Paragraph),
47    /// QR code.
48    Qr(String),
49}
50
51pub type Paragraph = Vec<Inline>;
52
53#[derive(Serialize, Deserialize, Clone, Debug)]
54pub struct Inline {
55    pub kind: InlineKind,
56    pub content: String,
57}
58
59#[derive(Serialize, Deserialize, Clone, Copy, Debug)]
60pub enum InlineKind {
61    /// Plain text.
62    Plain,
63    /// Bold text.
64    Bold,
65    /// Italic text.
66    Italic,
67    /// Inline image.
68    Image,
69    /// Inline icon image.
70    Icon,
71    /// Line break.
72    Br,
73}