-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std: Stabilize the net
module
#23352
Conversation
This commit performs a stabilization pass over the std::net module, incorporating the changes from RFC 923. Specifically, the following actions were taken: Stable functionality: * `net` (the name) * `Shutdown` * `Shutdown::{Read, Write, Both}` * `lookup_host` * `LookupHost` * `SocketAddr` * `SocketAddr::{V4, V6}` * `SocketAddr::port` * `SocketAddrV4` * `SocketAddrV4::{new, ip, port}` * `SocketAddrV6` * `SocketAddrV4::{new, ip, port, flowinfo, scope_id}` * Common trait impls for socket addr structures * `ToSocketAddrs` * `ToSocketAddrs::Iter` * `ToSocketAddrs::to_socket_addrs` * `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}` * `Ipv4Addr` * `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}` * `Ipv6Addr` * `Ipv6Addr::{new, segments, to_ipv4}` * `TcpStream` * `TcpStream::connect` * `TcpStream::{peer_addr, local_addr, shutdown, try_clone}` * `{Read,Write} for {TcpStream, &TcpStream}` * `TcpListener` * `TcpListener::bind` * `TcpListener::{local_addr, try_clone, accept, incoming}` * `Incoming` * `UdpSocket` * `UdpSocket::bind` * `UdpSocket::{recv_from, send_to, local_addr, try_clone}` Unstable functionality: * Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address and determining qualities of it. * Extra methods on `TcpStream` to configure various protocol options. * Extra methods on `UdpSocket` to configure various protocol options. Deprecated functionality: * The `socket_addr` method has been renamed to `local_addr` This commit is a breaking change due to the restructuring of the `SocketAddr` type as well as the renaming of the `socket_addr` method. Migration should be fairly straightforward, however, after accounting for the new level of abstraction in `SocketAddr` (protocol distinction at the socket address level, not the IP address). [breaking-change]
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
Note that this should not be merged before rust-lang/rfcs#923 is decided on. r? @aturon |
cc @sfackler |
#[stable(feature = "rust1", since = "1.0.0")] | ||
pub fn ip(&self) -> &Ipv4Addr { | ||
unsafe { | ||
&*(&self.inner.sin_addr as *const libc::in_addr as *const Ipv4Addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit sketch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes unfortunately I wasn't sure of a great way to do this otherwise. Given a type definition of struct T(U)
I don't think we have a safe way to go from &U
to &T
, although it should indeed work out in terms of representation.
This LGTM. r=me once the RFC is accepted. |
This commit performs a stabilization pass over the std::net module, incorporating the changes from RFC 923. Specifically, the following actions were taken: Stable functionality: * `net` (the name) * `Shutdown` * `Shutdown::{Read, Write, Both}` * `lookup_host` * `LookupHost` * `SocketAddr` * `SocketAddr::{V4, V6}` * `SocketAddr::port` * `SocketAddrV4` * `SocketAddrV4::{new, ip, port}` * `SocketAddrV6` * `SocketAddrV4::{new, ip, port, flowinfo, scope_id}` * Common trait impls for socket addr structures * `ToSocketAddrs` * `ToSocketAddrs::Iter` * `ToSocketAddrs::to_socket_addrs` * `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}` * `Ipv4Addr` * `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}` * `Ipv6Addr` * `Ipv6Addr::{new, segments, to_ipv4}` * `TcpStream` * `TcpStream::connect` * `TcpStream::{peer_addr, local_addr, shutdown, try_clone}` * `{Read,Write} for {TcpStream, &TcpStream}` * `TcpListener` * `TcpListener::bind` * `TcpListener::{local_addr, try_clone, accept, incoming}` * `Incoming` * `UdpSocket` * `UdpSocket::bind` * `UdpSocket::{recv_from, send_to, local_addr, try_clone}` Unstable functionality: * Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address and determining qualities of it. * Extra methods on `TcpStream` to configure various protocol options. * Extra methods on `UdpSocket` to configure various protocol options. Deprecated functionality: * The `socket_addr` method has been renamed to `local_addr` This commit is a breaking change due to the restructuring of the `SocketAddr` type as well as the renaming of the `socket_addr` method. Migration should be fairly straightforward, however, after accounting for the new level of abstraction in `SocketAddr` (protocol distinction at the socket address level, not the IP address). [breaking-change]
This commit performs a stabilization pass over the std::net module,
incorporating the changes from RFC 923. Specifically, the following actions were
taken:
Stable functionality:
net
(the name)Shutdown
Shutdown::{Read, Write, Both}
lookup_host
LookupHost
SocketAddr
SocketAddr::{V4, V6}
SocketAddr::port
SocketAddrV4
SocketAddrV4::{new, ip, port}
SocketAddrV6
SocketAddrV4::{new, ip, port, flowinfo, scope_id}
ToSocketAddrs
ToSocketAddrs::Iter
ToSocketAddrs::to_socket_addrs
ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}
Ipv4Addr
Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}
Ipv6Addr
Ipv6Addr::{new, segments, to_ipv4}
TcpStream
TcpStream::connect
TcpStream::{peer_addr, local_addr, shutdown, try_clone}
{Read,Write} for {TcpStream, &TcpStream}
TcpListener
TcpListener::bind
TcpListener::{local_addr, try_clone, accept, incoming}
Incoming
UdpSocket
UdpSocket::bind
UdpSocket::{recv_from, send_to, local_addr, try_clone}
Unstable functionality:
Ipv{4,6}Addr
for various methods of inspecting the addressand determining qualities of it.
TcpStream
to configure various protocol options.UdpSocket
to configure various protocol options.Deprecated functionality:
socket_addr
method has been renamed tolocal_addr
This commit is a breaking change due to the restructuring of the
SocketAddr
type as well as the renaming of the
socket_addr
method. Migration should befairly straightforward, however, after accounting for the new level of
abstraction in
SocketAddr
(protocol distinction at the socket address level,not the IP address).
[breaking-change]