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
use serde::{Deserialize, Serialize};

///User OID wrapper
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserId(pub bson::oid::ObjectId);

impl UserId {
    ///Create a new bson OID
    pub fn new() -> Self {
        UserId(bson::oid::ObjectId::new())
    }
}

///New User model allowed to be sent over the wire and stored
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NewUser {
    pub username: String,
    pub password: String,
}

///Basic User model
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct User {
    pub oid: UserId,
    pub username: String,
    pub password: String,
}

///Update user model allowed to be sent over the wire and stored
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpdateUser {
    pub oid: UserId,
    pub username: String,
    pub password: String,
}