appslib/dto/
rating_level_response.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct RatingLevelResponse {
    pub user: Uuid,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub level: Option<i32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max: Option<i32>,
}

impl RatingLevelResponse {
    pub fn from_rating_level(
        user: Uuid,
        level: Option<i32>,
        max: Option<i32>,
    ) -> RatingLevelResponse {
        RatingLevelResponse { user, level, max }
    }
}