summaryrefslogtreecommitdiff
path: root/server/src/api_model.rs
blob: 4b6ecedbfe568cc52c5527cbb92ee6e5919b15ec (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
39
40
41
42
43
44
45
46
use serde::{Serialize};

#[derive(Serialize, Copy, Clone)]
pub enum ReviewState {
    DRAFT,
    OPEN,
    DROPPED,
    CLOSED,
}

#[derive(Serialize)]
pub struct User<'r> {
    pub username: &'r str,
    pub name: &'r str,
    pub active: bool,
}

#[derive(Serialize)]
pub struct Review<'r> {
    pub id: u64,
    pub title: &'r str,
    pub description: &'r str,
    pub owner: &'r User<'r>,
    pub reviewers: Vec<&'r User<'r>>,
    pub watchers: Vec<&'r User<'r>>,
    pub state: ReviewState,
    pub progress: f64,
}

#[derive(Serialize)]
pub struct ReviewEntry<'r> {
    pub id: u64,
    pub title: &'r str,
    pub owner: &'r User<'r>,
    pub state: ReviewState,
    pub progress: f64,
}

#[derive(Serialize)]
pub struct Reviews<'r> {
    pub offset: u32,
    pub limit: u32,
    pub total_count: u32,
    pub more: bool,
    pub reviews: Vec<ReviewEntry<'r>>,
}