1
+ use dox:: { Hash , Hasher } ;
1
2
use dox:: mem;
2
3
3
4
pub type rlim_t = c_ulong ;
@@ -9,18 +10,21 @@ pub type tcflag_t = ::c_uint;
9
10
pub enum timezone { }
10
11
11
12
s ! {
13
+ #[ derive( Eq , Hash , PartialEq ) ]
12
14
pub struct sockaddr {
13
15
pub sa_family: sa_family_t,
14
16
pub sa_data: [ :: c_char; 14 ] ,
15
17
}
16
18
19
+ #[ derive( Eq , Hash , PartialEq ) ]
17
20
pub struct sockaddr_in {
18
21
pub sin_family: sa_family_t,
19
22
pub sin_port: :: in_port_t,
20
23
pub sin_addr: :: in_addr,
21
24
pub sin_zero: [ u8 ; 8 ] ,
22
25
}
23
26
27
+ #[ derive( Eq , Hash , PartialEq ) ]
24
28
pub struct sockaddr_in6 {
25
29
pub sin6_family: sa_family_t,
26
30
pub sin6_port: :: in_port_t,
61
65
pub ai_next: * mut addrinfo,
62
66
}
63
67
68
+ #[ derive( Eq , Hash , PartialEq ) ]
64
69
pub struct sockaddr_ll {
65
70
pub sll_family: :: c_ushort,
66
71
pub sll_protocol: :: c_ushort,
@@ -125,6 +130,21 @@ s! {
125
130
}
126
131
}
127
132
133
+ impl PartialEq for sockaddr_un {
134
+ fn eq ( & self , other : & sockaddr_un ) -> bool {
135
+ self . sun_family == other. sun_family && & self . sun_path [ ..] == & other. sun_path [ ..]
136
+ }
137
+ }
138
+
139
+ impl Eq for sockaddr_un { }
140
+
141
+ impl Hash for sockaddr_un {
142
+ fn hash < H > ( & self , state : & mut H ) where H : Hasher {
143
+ self . sun_family . hash ( state) ;
144
+ & self . sun_path [ ..] . hash ( state) ;
145
+ }
146
+ }
147
+
128
148
// intentionally not public, only used for fd_set
129
149
#[ cfg( target_pointer_width = "32" ) ]
130
150
const ULONG_SIZE : usize = 32 ;
0 commit comments