@@ -18,7 +18,21 @@ impl AnnounceInterval {
18
18
}
19
19
}
20
20
21
- #[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
21
+ impl Ord for AnnounceInterval {
22
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
23
+ self . 0 . get ( ) . cmp ( & other. 0 . get ( ) )
24
+ }
25
+ }
26
+
27
+ impl PartialOrd for AnnounceInterval {
28
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
29
+ Some ( self . cmp ( & other) )
30
+ }
31
+ }
32
+
33
+ #[ derive(
34
+ PartialEq , Eq , PartialOrd , Ord , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ,
35
+ ) ]
22
36
#[ repr( transparent) ]
23
37
pub struct InfoHash ( pub [ u8 ; 20 ] ) ;
24
38
@@ -32,6 +46,18 @@ impl ConnectionId {
32
46
}
33
47
}
34
48
49
+ impl Ord for ConnectionId {
50
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
51
+ self . 0 . get ( ) . cmp ( & other. 0 . get ( ) )
52
+ }
53
+ }
54
+
55
+ impl PartialOrd for ConnectionId {
56
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
57
+ Some ( self . cmp ( & other) )
58
+ }
59
+ }
60
+
35
61
#[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
36
62
#[ repr( transparent) ]
37
63
pub struct TransactionId ( pub I32 ) ;
@@ -42,6 +68,18 @@ impl TransactionId {
42
68
}
43
69
}
44
70
71
+ impl Ord for TransactionId {
72
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
73
+ self . 0 . get ( ) . cmp ( & other. 0 . get ( ) )
74
+ }
75
+ }
76
+
77
+ impl PartialOrd for TransactionId {
78
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
79
+ Some ( self . cmp ( & other) )
80
+ }
81
+ }
82
+
45
83
#[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
46
84
#[ repr( transparent) ]
47
85
pub struct NumberOfBytes ( pub I64 ) ;
@@ -52,6 +90,18 @@ impl NumberOfBytes {
52
90
}
53
91
}
54
92
93
+ impl Ord for NumberOfBytes {
94
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
95
+ self . 0 . get ( ) . cmp ( & other. 0 . get ( ) )
96
+ }
97
+ }
98
+
99
+ impl PartialOrd for NumberOfBytes {
100
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
101
+ Some ( self . cmp ( & other) )
102
+ }
103
+ }
104
+
55
105
#[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
56
106
#[ repr( transparent) ]
57
107
pub struct NumberOfPeers ( pub I32 ) ;
@@ -62,6 +112,18 @@ impl NumberOfPeers {
62
112
}
63
113
}
64
114
115
+ impl Ord for NumberOfPeers {
116
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
117
+ self . 0 . get ( ) . cmp ( & other. 0 . get ( ) )
118
+ }
119
+ }
120
+
121
+ impl PartialOrd for NumberOfPeers {
122
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
123
+ Some ( self . cmp ( & other) )
124
+ }
125
+ }
126
+
65
127
#[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
66
128
#[ repr( transparent) ]
67
129
pub struct NumberOfDownloads ( pub I32 ) ;
@@ -72,6 +134,18 @@ impl NumberOfDownloads {
72
134
}
73
135
}
74
136
137
+ impl Ord for NumberOfDownloads {
138
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
139
+ self . 0 . get ( ) . cmp ( & other. 0 . get ( ) )
140
+ }
141
+ }
142
+
143
+ impl PartialOrd for NumberOfDownloads {
144
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
145
+ Some ( self . cmp ( & other) )
146
+ }
147
+ }
148
+
75
149
#[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
76
150
#[ repr( transparent) ]
77
151
pub struct Port ( pub U16 ) ;
@@ -82,6 +156,18 @@ impl Port {
82
156
}
83
157
}
84
158
159
+ impl Ord for Port {
160
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
161
+ self . 0 . get ( ) . cmp ( & other. 0 . get ( ) )
162
+ }
163
+ }
164
+
165
+ impl PartialOrd for Port {
166
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
167
+ Some ( self . cmp ( & other) )
168
+ }
169
+ }
170
+
85
171
#[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
86
172
#[ repr( transparent) ]
87
173
pub struct PeerKey ( pub I32 ) ;
@@ -92,14 +178,30 @@ impl PeerKey {
92
178
}
93
179
}
94
180
95
- #[ derive( PartialEq , Eq , Clone , Copy , Debug , Hash , AsBytes , FromBytes , FromZeroes ) ]
181
+ impl Ord for PeerKey {
182
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
183
+ self . 0 . get ( ) . cmp ( & other. 0 . get ( ) )
184
+ }
185
+ }
186
+
187
+ impl PartialOrd for PeerKey {
188
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
189
+ Some ( self . cmp ( & other) )
190
+ }
191
+ }
192
+
193
+ #[ derive(
194
+ PartialEq , Eq , PartialOrd , Ord , Clone , Copy , Debug , Hash , AsBytes , FromBytes , FromZeroes ,
195
+ ) ]
96
196
#[ repr( C , packed) ]
97
197
pub struct ResponsePeer < I : Ip > {
98
198
pub ip_address : I ,
99
199
pub port : Port ,
100
200
}
101
201
102
- #[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
202
+ #[ derive(
203
+ PartialEq , Eq , PartialOrd , Ord , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ,
204
+ ) ]
103
205
#[ repr( transparent) ]
104
206
pub struct Ipv4AddrBytes ( pub [ u8 ; 4 ] ) ;
105
207
@@ -117,7 +219,9 @@ impl From<Ipv4Addr> for Ipv4AddrBytes {
117
219
}
118
220
}
119
221
120
- #[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ) ]
222
+ #[ derive(
223
+ PartialEq , Eq , PartialOrd , Ord , Hash , Clone , Copy , Debug , AsBytes , FromBytes , FromZeroes ,
224
+ ) ]
121
225
#[ repr( transparent) ]
122
226
pub struct Ipv6AddrBytes ( pub [ u8 ; 16 ] ) ;
123
227
0 commit comments