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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#[derive(Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct ProfileName(String);
impl From<String> for ProfileName {
fn from(s: String) -> Self {
ProfileName(s)
}
}
/// A profile
///
/// A profile can be _any_ profile, not only the profile of the user
#[derive(Debug)]
pub struct Profile {
repository: Repository,
}
impl Profile {
/// Create a new Profile.
///
/// One does not want this most of the time, see `load`. Use this only for creating a
/// completely new profile
pub fn new(repository: Repository) -> Result<Self, Error> {
unimplemented!()
}
/// Load a profile from the repository
pub fn load(repository: Repository, key: Key) -> Result<Self, Error> {
unimplemented!()
}
pub fn blocks(&self) -> impl Iterator<Item = Result<Block, Error>> {
use crate::repository::iter::block::BlockIterator;
BlockIterator::new(&self.repository)
}
}
/// The profile of the user of the application
///
/// Internally this wraps the `Profile` type, but it provides more functionality, for example
/// posting new content.
///
#[derive(Debug)]
pub struct UserProfile {
profile: Profile
}
impl UserProfile {
/// Create a new Profile.
///
/// One does not want this most of the time, see `load`. Use this only for creating a
/// completely new profile
pub fn new(repository: Repository) -> Result<Self, Error> {
Ok(UserProfile {
profile: Profile::new(repository)?,
})
}
/// Load a profile from the repository
pub fn load(repository: Repository, key: Key) -> Result<Self, Error> {
Ok(UserProfile {
profile: Profile::load(repository, key)?,
})
}
}
|