Completely refactor project structure
parent: tbd commit: ae8ff44
1 | use ; |
2 | use FromStr; |
3 | |
4 | use ; |
5 | |
6 | use Instance; |
7 | |
8 | /// A user, defined by its username and instance. |
9 | /// |
10 | /// # Textual Format |
11 | /// A user's textual reference is defined as: |
12 | /// |
13 | /// `{username: String}:{instance: Instance}` |
14 | /// |
15 | /// # Examples |
16 | /// For the user with the username `barson` and the instance `giterated.dev`, |
17 | /// the following [`User`] initialization would be valid: |
18 | /// |
19 | /// ``` |
20 | /// let user = User { |
21 | /// username: String::from("barson"), |
22 | /// instance: Instance::from_str("giterated.dev").unwrap() |
23 | /// }; |
24 | /// |
25 | /// // This is correct |
26 | /// assert_eq!(User::from_str("barson:giterated.dev").unwrap(), user); |
27 | /// ``` |
28 | |
29 | |
30 | pub username: String, |
31 | pub instance: Instance, |
32 | |
33 | |
34 | |
35 | |
36 | write! |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | unwrap | from_str .
43 | |
44 | |
45 | |
46 | |
47 | type Err = ; |
48 | |
49 | |
50 | let mut colon_split = s.split; |
51 | let username = colon_split.next .unwrap .to_string; |
52 | let instance = from_str .unwrap; |
53 | |
54 | Ok |
55 | |
56 | |
57 |