Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

std: Stabilize the net module #23352

Merged
merged 1 commit into from
Mar 17, 2015
Merged

Conversation

alexcrichton
Copy link
Member

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}`
* 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]
@rust-highfive
Copy link
Contributor

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member Author

Note that this should not be merged before rust-lang/rfcs#923 is decided on.

r? @aturon

@rust-highfive rust-highfive assigned aturon and unassigned brson Mar 13, 2015
@aturon
Copy link
Member

aturon commented Mar 14, 2015

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)
Copy link
Member

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

Copy link
Member Author

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.

@aturon aturon mentioned this pull request Mar 16, 2015
91 tasks
@aturon
Copy link
Member

aturon commented Mar 16, 2015

This LGTM. r=me once the RFC is accepted.

@aturon
Copy link
Member

aturon commented Mar 16, 2015

@bors: r+ f798674

@bors
Copy link
Collaborator

bors commented Mar 17, 2015

⌛ Testing commit f798674 with merge a257288...

bors added a commit that referenced this pull request Mar 17, 2015
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]
@bors bors merged commit f798674 into rust-lang:master Mar 17, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants