diff options
| author | Linus Färnstrand <faern@faern.net> | 2022-07-17 09:48:56 +0200 |
|---|---|---|
| committer | Linus Färnstrand <faern@faern.net> | 2022-07-17 09:48:56 +0200 |
| commit | b20b69a79b4e8bfc3574c767ec798d356d33045d (patch) | |
| tree | 9ad137a9a8488687d219ae992315bb615c6c72a7 /library/std/src/net | |
| parent | 7aabd85faa9e78e40161839b14946c5aa6750086 (diff) | |
| download | rust-b20b69a79b4e8bfc3574c767ec798d356d33045d.tar.gz rust-b20b69a79b4e8bfc3574c767ec798d356d33045d.zip | |
Move SocketAddrCRepr to sys_common
Diffstat (limited to 'library/std/src/net')
| -rw-r--r-- | library/std/src/net/addr.rs | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/library/std/src/net/addr.rs b/library/std/src/net/addr.rs index 13d85f23035..53fee952a7a 100644 --- a/library/std/src/net/addr.rs +++ b/library/std/src/net/addr.rs @@ -596,37 +596,6 @@ impl<I: Into<IpAddr>> From<(I, u16)> for SocketAddr { } } -/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level -/// SocketAddr* types into their system representation. The benefit of this specific -/// type over using `c::sockaddr_storage` is that this type is exactly as large as it -/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust. -#[repr(C)] -pub(crate) union SocketAddrCRepr { - v4: c::sockaddr_in, - v6: c::sockaddr_in6, -} - -impl SocketAddrCRepr { - pub fn as_ptr(&self) -> *const c::sockaddr { - self as *const _ as *const c::sockaddr - } -} - -impl<'a> IntoInner<(SocketAddrCRepr, c::socklen_t)> for &'a SocketAddr { - fn into_inner(self) -> (SocketAddrCRepr, c::socklen_t) { - match *self { - SocketAddr::V4(ref a) => { - let sockaddr = SocketAddrCRepr { v4: a.into_inner() }; - (sockaddr, mem::size_of::<c::sockaddr_in>() as c::socklen_t) - } - SocketAddr::V6(ref a) => { - let sockaddr = SocketAddrCRepr { v6: a.into_inner() }; - (sockaddr, mem::size_of::<c::sockaddr_in6>() as c::socklen_t) - } - } - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for SocketAddr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
