1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// This file is part of file-descriptors. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/file-descriptors/master/COPYRIGHT. No part of file-descriptors, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2018-2019 The developers of file-descriptors. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/file-descriptors/master/COPYRIGHT.
/// Whilst this is present in libc, it is not always consistently defined.
#[derive(Clone)]
#[repr(C)]
pub(crate) struct sockaddr_storage
{
/// Socket address family.
ss_family: sa_family_t,
/// Alignment.
__ss_align: size_t,
/// Padding to 128 bytes.
__ss_pad2: [u8; 128 - size_of::<sa_family_t>() - size_of::<size_t>()],
}
impl Debug for sockaddr_storage
{
#[inline(always)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
{
write!(f, "sockaddr_storage {{ ss_family: {} }}", self.ss_family)
}
}
impl PartialEq for sockaddr_storage
{
#[inline(always)]
fn eq(&self, other: &Self) -> bool
{
self.ss_family == other.ss_family && self.__ss_align == other.__ss_align && (&self.__ss_pad2[..]) == (&other.__ss_pad2[..])
}
}
impl Eq for sockaddr_storage
{
}
impl PartialOrd for sockaddr_storage
{
#[inline(always)]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
{
Some(self.cmp(other))
}
}
impl Ord for sockaddr_storage
{
#[inline(always)]
fn cmp(&self, other: &Self) -> Ordering
{
self.ss_family.cmp(&other.ss_family).then_with(|| self.__ss_align.cmp(&other.__ss_align)).then_with(|| (&self.__ss_pad2[..]).cmp(&self.__ss_pad2[..]))
}
}
impl Hash for sockaddr_storage
{
#[inline(always)]
fn hash<H: Hasher>(&self, hasher: &mut H)
{
self.ss_family.hash(hasher);
self.__ss_align.hash(hasher);
(&self.__ss_pad2[..]).hash(hasher);
}
}