Progress on refactor
parent: tbd commit: c9f076f
1 | use ; |
2 | use FromStr; |
3 | |
4 | use ; |
5 | use ; |
6 | |
7 | use crate GiteratedObject; |
8 | |
9 | use Instance; |
10 | |
11 | /// A user, defined by its username and instance. |
12 | /// |
13 | /// # Textual Format |
14 | /// A user's textual reference is defined as: |
15 | /// |
16 | /// `{username: String}:{instance: Instance}` |
17 | /// |
18 | /// # Examples |
19 | /// For the user with the username `barson` and the instance `giterated.dev`, |
20 | /// the following [`User`] initialization would be valid: |
21 | /// |
22 | /// ``` |
23 | /// let user = User { |
24 | /// username: String::from("barson"), |
25 | /// instance: Instance::from_str("giterated.dev").unwrap() |
26 | /// }; |
27 | /// |
28 | /// // This is correct |
29 | /// assert_eq!(User::from_str("barson:giterated.dev").unwrap(), user); |
30 | /// ``` |
31 | |
32 | |
33 | pub username: String, |
34 | pub instance: Instance, |
35 | |
36 | |
37 | |
38 | |
39 | "user" |
40 | |
41 | |
42 | |
43 | Ok |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | write! |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | unwrap | from_str .
56 | |
57 | |
58 | |
59 | |
60 | type Err = ; |
61 | |
62 | |
63 | let mut colon_split = s.split; |
64 | let username = colon_split.next .unwrap .to_string; |
65 | let instance = from_str .unwrap; |
66 | |
67 | Ok |
68 | |
69 | |
70 | |
71 | |
72 | ; |
73 | |
74 | |
75 | |
76 | self.0.zeroize |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 |