aboutsummaryrefslogtreecommitdiff
path: root/common/src/api.rs
blob: 111ae57b1d84aa21cce56e8e728e94e228cbece1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2025 metamuffin <metamuffin.org>
*/

use crate::{user::NodeUserData, Node};
use serde::{Deserialize, Serialize};
use std::sync::Arc;

type NodesWithUdata = Vec<(Arc<Node>, NodeUserData)>;

#[derive(Serialize, Deserialize)]
pub struct ApiNodeResponse {
    pub parents: NodesWithUdata,
    pub children: NodesWithUdata,
    pub node: Arc<Node>,
    pub userdata: NodeUserData,
}

#[derive(Serialize, Deserialize)]
pub struct ApiSearchResponse {
    pub count: usize,
    pub results: NodesWithUdata,
}

#[derive(Serialize, Deserialize)]
pub struct ApiItemsResponse {
    pub count: usize,
    pub pages: usize,
    pub items: NodesWithUdata,
}

#[derive(Serialize, Deserialize)]
pub struct ApiHomeResponse {
    pub toplevel: NodesWithUdata,
    pub categories: Vec<(String, NodesWithUdata)>,
}