about summary refs log tree commit diff
path: root/library/std/src/net
AgeCommit message (Collapse)AuthorLines
2020-10-13Use is_ok() instead of empty Ok(_)wcampbell-10/+4
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2020-10-06Parse SocketAddrV6::scope_idTamir Duberstein-4/+15
2020-10-06Avoid unused returnTamir Duberstein-9/+12
2020-10-06Rollup merge of #77528 - tamird:avoid-cast-net-parser, r=dtolnayYuki Okushi-36/+48
Avoid unchecked casts in net parser Once this and #77426 are in, I'll send another PR adding scope id parsing. r? @dtolnay
2020-10-04Inline "eof" methodsTamir Duberstein-13/+2
2020-10-04Avoid unchecked casts in net parserTamir Duberstein-23/+46
2020-10-04Include scope id in SocketAddrV6::DisplayTamir Duberstein-3/+19
2020-09-25Rollup merge of #76304 - CDirkx:const-ip, r=ecstatic-morseJonas Schievink-5/+29
Make delegation methods of `std::net::IpAddr` unstably const Make the following methods of `std::net::IpAddr` unstable const under the `const_ip` feature: - `is_unspecified` - `is_loopback` - `is_global` - `is_multicast` Also adds a test for these methods in a const context. Possible because these methods delegate to the inner `Ipv4Addr` or `Ipv6Addr`, which were made const ([PR#76205](https://github.com/rust-lang/rust/pull/76142) and [PR#76206](https://github.com/rust-lang/rust/pull/76206)), and the recent stabilization of const control flow. Part of #76205 r? @ecstatic-morse
2020-09-23Make delegation methods of `std::net::IpAddr` unstable constChristiaan Dirkx-5/+29
Make the following methods of `std::net::IpAddr` unstable const under the `const_ip` feature: - `is_unspecified` - `is_loopback` - `is_global` - `is_multicast` Also adds a test for these methods in a const context. Possible because these methods delegate to the inner `Ipv4Addr` or `Ipv6Addr`, which were made const, and the recent stabilization of const control flow. Part of #76205
2020-09-22Update library/std/src/net/addr.rsImbolc-1/+1
Co-authored-by: Ivan Tham <pickfire@riseup.net>
2020-09-22Update library/std/src/net/addr.rsImbolc-1/+1
Co-authored-by: Ivan Tham <pickfire@riseup.net>
2020-09-22Update addr.rsImbolc-1/+1
I little clarification
2020-09-03Make `Ipv4Addr` and `Ipv6Addr` const tests unit tests under `library`Christiaan Dirkx-0/+109
These tests are about the standard library, not the compiler itself, thus should live in `library`, see #76268.
2020-09-03Auto merge of #76235 - jyn514:std-intra-links, r=poliorceticsbors-46/+0
Convert many files to intra-doc links Helps with https://github.com/rust-lang/rust/issues/75080 r? @poliorcetics I recommend reviewing one commit at a time, but the diff is small enough you can do it all at once if you like :)
2020-09-03Rollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morseDylan DPC-18/+38
Make all methods of `std::net::Ipv4Addr` const Make the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature: - `octets` - `is_loopback` - `is_private` - `is_link_local` - `is_global` (unstable) - `is_shared` (unstable) - `is_ietf_protocol_assignment` (unstable) - `is_benchmarking` (unstable) - `is_reserved` (unstable) - `is_multicast` - `is_broadcast` - `is_documentation` - `to_ipv6_compatible` - `to_ipv6_mapped` This would make all methods of `Ipv6Addr` const. Of these methods, `is_global`, `is_broadcast`, `to_ipv6_compatible`, and `to_ipv6_mapped` require a change in implementation. Part of #76205
2020-09-02Convert many files to intra-doc linksJoshua Nelson-4/+0
- Use intra-doc links for `std::io` in `std::fs` - Use intra-doc links for File::read in unix/ext/fs.rs - Remove explicit intra-doc links for `true` in `net/addr.rs` - Use intra-doc links in alloc/src/sync.rs - Use intra-doc links in src/ascii.rs - Switch to intra-doc links in alloc/rc.rs - Use intra-doc links in core/pin.rs - Use intra-doc links in std/prelude - Use shorter links in `std/fs.rs` `io` is already in scope.
2020-09-02add a note for Ipv4Addr::to_ipv6_compatible南浦月-0/+3
2020-09-01Remove explicit links to `true` and `false` in ip.rsJoshua Nelson-42/+0
2020-09-01Make all remaining methods of `std::net::Ipv4Addr` constChristiaan Dirkx-9/+20
Makes the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature: - `is_global` - `is_reserved` - `is_broadcast` - `to_ipv6_compatible` - `to_ipv6_mapped` This results in all methods of `Ipv4Addr` being const. Also adds tests for these methods in a const context.
2020-09-01Change implementation of `Ipv6Addr::is_unspecified` and `is_loopback` from ↵CDirkx-2/+2
`matches!` to `u128` comparison Done because `matches!` doesn't optimize well with array comparisons
2020-09-01Make methods unstable const under `const_ipv4`CDirkx-9/+9
2020-09-01Make all methods of `std::net::Ipv6Addr` constCDirkx-16/+30
Make the following methods of `std::net::Ipv6Addr` unstable const under the `const_ipv6` feature: - `segments` - `is_unspecified` - `is_loopback` - `is_global` (unstable) - `is_unique_local` - `is_unicast_link_local_strict` - `is_documentation` - `multicast_scope` - `is_multicast` - `to_ipv4_mapped` - `to_ipv4` Changed the implementation of `is_unspecified` and `is_loopback` to use a `match` instead of `==`. Part of #76205
2020-08-31Make more Ipv4Addr methods constCDirkx-9/+18
Constify the following methods of `std::net::Ipv4Addr`: - `octets` - `is_loopback` - `is_private` - `is_link_local` - `is_shared` - `is_ietf_protocol_assignment` - `is_benchmarking` - `is_multicast` - `is_documentation` Also insta-stabilizes these methods as const. Possible because of the stabilization of const integer arithmetic and control flow.
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-2478/+2430
Also doing fmt inplace as requested.
2020-08-19Minor changes to Ipv4AddrLzu Tao-7/+14
* Impl IntoInner rather than AsInner for Ipv4Addr * Add some comments * Add test to show endiannes of Ipv4Addr display
2020-08-16Fix a link, improve method resolutionAlexis Bourget-24/+27
2020-08-15Move to intra doc links in std::netAlexis Bourget-293/+139
2020-08-14Rollup merge of #74409 - ↵Tyler Mandry-2/+16
LukasKalbertodt:improve-debug-impl-of-socketaddr-ipaddr, r=Amanieu Change Debug impl of SocketAddr and IpAddr to match their Display output This has already been done for `SocketAddrV4`, `SocketAddrV6`, `IpAddrV4` and `IpAddrV6`. I don't see a point to keep the rather bad to read derived impl, especially so when pretty printing: V4( 127.0.0.1 ) From the `Display`, one can easily and unambiguously see if it's V4 or V6. Two examples: ``` 127.0.0.1:443 [2001:db8:85a3::8a2e:370:7334]:443 ``` Luckily the docs explicitly state that `Debug` output is not stable and that it may be changed at any time. Using `Display` as `Debug` is very convenient for configuration structs (e.g. for webservers) that often just have a `derive(Debug)` and are printed that way to the one starting the server.
2020-08-12Auto merge of #75019 - nanpuyue:to_ipv4_mapped, r=LukasKalbertodtbors-0/+40
Add Ipv6Addr::to_ipv4_mapped * add Ipv6Addr::to_ipv4_mapped * ~~deprecate Ipv4Addr::to_ipv6_compatible & Ipv6Addr::to_ipv4~~ reference: #75150 According to [IETF RFC 4291](https://tools.ietf.org/html/rfc4291#page-10), the "IPv4-Compatible IPv6 address" is deprecated. > 2.5.5.1. IPv4-Compatible IPv6 Address > > The "IPv4-Compatible IPv6 address" was defined to assist in the IPv6 > transition. The format of the "IPv4-Compatible IPv6 address" is as > follows: > > | 80 bits | 16 | 32 bits | > +--------------------------------------+--------------------------+ > |0000..............................0000|0000| IPv4 address | > +--------------------------------------+----+---------------------+ > > Note: The IPv4 address used in the "IPv4-Compatible IPv6 address" > must be a globally-unique IPv4 unicast address. > > The "IPv4-Compatible IPv6 address" is now deprecated because the > current IPv6 transition mechanisms no longer use these addresses. > New or updated implementations are not required to support this > address type. And the current implementation of `Ipv4Addr::to_ipv6_compatible`is incorrect: it does not check whether the IPv4 address is a globally-unique IPv4 unicast address. Please let me know if there are any issues with this pull request.
2020-08-11prefer pattern matching over indexingLzu Tao-13/+10
2020-08-11add Ipv6Addr::to_ipv4_mapped南浦月-0/+40
2020-08-10Transmute between big endian `s6_addr` and `[u16; 8]`.Lzu Tao-27/+27
The old code already made the assumption to reinterpret `Ipv6Addr` as `[u16; 8]`. Glibc, Linux, FreeBSD, Win32 all makes this assumption. The main motivation of using union it to better optimize code. ref: * https://docs.microsoft.com/en-us/windows/win32/api/in6addr/ns-in6addr-in6_addr * https://github.com/freebsd/freebsd/blob/1d6e4247415d264485ee94b59fdbc12e0c566fd0/contrib/ntp/lib/isc/include/isc/ipv6.h#L63 * https://github.com/zephyrproject-rtos/zephyr/blob/8b531aa996bba254c03129658490af59597acd78/include/net/net_ip.h#L137 * https://sourceware.org/git/?p=glibc.git;a=blob;f=inet/netinet/in.h;h=f6355c7efe5192b88337b136ef687fe9a5ed648c;hb=HEAD#l216 Co-authored-by: Josh Stone <cuviper@gmail.com> Co-authored-by: Peter Atashian <retep998@gmail.com>
2020-08-07Rollup merge of #75179 - lzutao:unsed-ipv4-frominner, r=alexcrichtonYuki Okushi-5/+0
Remove unused FromInner impl for Ipv4Addr The removed is a unused unstable implementation.
2020-08-07Rollup merge of #75175 - lzutao:doctest-ipv4-fromu32, r=cuviperYuki Okushi-4/+4
Make doctests of Ipv4Addr::from(u32) easier to read There are many zeroes in `0x0d0c0b0au32` which makes it hard to read.
2020-08-05Remove unused FromInner impl for Ipv4AddrLzu Tao-5/+0
2020-08-05Make doctests of Ipv4Addr::from(u32) easier to readLzu Tao-4/+4
2020-08-05Use u32::from_ne_bytes to fix a FIXMELzu Tao-9/+3
Co-authored-by: Weiyi Wang <wwylele@gmail.com> Co-authored-by: Adam Reichold <adam.reichold@t-online.de> Co-authored-by: Josh Stone <cuviper@gmail.com> Co-authored-by: Scott McMurray <scottmcm@users.noreply.github.com> Co-authored-by: tmiasko <tomasz.miasko@gmail.com>
2020-07-28Add note to clearly mark the RFC as rejectedAlexis Bourget-0/+6
2020-07-28Remove links to rejected errata 4406 for RFC 4291Alexis Bourget-6/+0
2020-07-28Change Debug impl of SocketAddr and IpAddr to match their Display outputLukas Kalbertodt-2/+16
This has already been done for `SocketAddrV4`, `SocketAddrV6`, `IpAddrV4` and `IpAddrV6`. I don't see a point to keep the rather bad to read derived impl, especially when pretty printing: V4( 127.0.0.1 ) From the `Display`, one can easily and unambiguously see if it's V4 or V6. Using `Display` as `Debug` is very convenient for configuration structs (e.g. for webservers) that often just have a `derive(Debug)` and are printed that way to the user.
2020-07-27mv std libs to library/mark-0/+7686