Major post-refactor cleanup
parent: tbd commit: f90d7fb
1 | use ; |
2 | |
3 | use Error; |
4 | use Version; |
5 | |
6 | use crate MessageHandler; |
7 | use crate:: |
8 | , | ConnectionError
9 | , |
10 | , |
11 | validate_version, |
12 | ; |
13 | |
14 | use ; |
15 | |
16 | pub async |
17 | message: &NetworkMessage, |
18 | state: &ConnectionState, |
19 | |
20 | if initiate_handshake |
21 | .handle_message |
22 | .await |
23 | .is_ok |
24 | |
25 | Ok |
26 | else if handshake_response |
27 | .handle_message |
28 | .await |
29 | .is_ok |
30 | |
31 | Ok |
32 | else if handshake_finalize |
33 | .handle_message |
34 | .await |
35 | .is_ok |
36 | |
37 | Ok |
38 | else |
39 | Err |
40 | |
41 | |
42 | |
43 | async |
44 | Message | : ,
45 | State | : ,
46 | _instance: AuthenticatedInstance, |
47 | |
48 | if !validate_version |
49 | error! |
50 | "Version compatibility failure! Our Version: {}, Their Version: {}", |
51 | unwrap, | from_str .
52 | initiation.version |
53 | ; |
54 | |
55 | connection_state |
56 | .send |
57 | .await |
58 | .map_err?; |
59 | |
60 | Ok |
61 | else |
62 | connection_state |
63 | .send |
64 | .await |
65 | .map_err?; |
66 | |
67 | Ok |
68 | |
69 | |
70 | |
71 | async |
72 | Message | : ,
73 | State | : ,
74 | _instance: AuthenticatedInstance, |
75 | |
76 | if !validate_version |
77 | error! |
78 | "Version compatibility failure! Our Version: {}, Their Version: {}", |
79 | unwrap, | from_str .
80 | response.version |
81 | ; |
82 | |
83 | connection_state |
84 | .send |
85 | .await |
86 | .map_err?; |
87 | |
88 | Ok |
89 | else |
90 | connection_state |
91 | .send |
92 | .await |
93 | .map_err?; |
94 | |
95 | Ok |
96 | |
97 | |
98 | |
99 | async |
100 | Message | : ,
101 | State | : ,
102 | _instance: AuthenticatedInstance, |
103 | |
104 | if !finalize.success |
105 | error!; |
106 | return Err; |
107 | else |
108 | connection_state.handshaked.store; |
109 | |
110 | connection_state |
111 | .send |
112 | .await |
113 | .map_err?; |
114 | |
115 | Ok |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | |
122 | VersionMismatch, |
123 | |
124 | SendError, |
125 | |
126 | Other, |
127 | |
128 |