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
use super::{Entity, Repository, Result};
use std::ops::Deref;
use drawbridge_type::{RepositoryName, UserName, UserRecord};
use mime::APPLICATION_JSON;
#[repr(transparent)]
pub struct User<'a>(Entity<'a>);
impl<'a> Deref for User<'a> {
    type Target = Entity<'a>;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl<'a> User<'a> {
    pub fn new(entity: Entity<'a>, name: &UserName) -> Self {
        User(entity.child(&name.to_string()))
    }
    pub fn create(&self, conf: &UserRecord) -> Result<bool> {
        self.0.create_json(&APPLICATION_JSON, conf)
    }
    pub fn get(&self) -> Result<UserRecord> {
        self.0.get_json()
    }
    pub fn repository(&self, name: &RepositoryName) -> Repository<'a> {
        Repository::new(self.0.clone(), name)
    }
}