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