about summary refs log tree commit diff
path: root/src/libstd/net
AgeCommit message (Collapse)AuthorLines
2020-05-20Add fast-path optimization for Ipv4Addr::fmtNathan West-9/+16
2020-04-26Update nameSteven Fackler-8/+8
2020-04-26Add Read/Write::can_read/write_vectoredSteven Fackler-0/+20
When working with an arbitrary reader or writer, code that uses vectored operations may end up being slower than code that copies into a single buffer when the underlying reader or writer doesn't actually support vectored operations. These new methods allow you to ask the reader or witer up front if vectored operations are efficiently supported. Currently, you have to use some heuristics to guess by e.g. checking if the read or write only accessed the first buffer. Hyper is one concrete example of a library that has to do this dynamically: https://github.com/hyperium/hyper/blob/0eaf304644a396895a4ce1f0146e596640bb666a/src/proto/h1/io.rs#L582-L594
2020-03-20For issue 53957: revise unit tests to focus on underlying bug of 23076.Felix S. Klock II-4/+19
Namely, this version focuses on the end-to-end behavior that the attempt to create the UDP binding will fail, regardless of the semantics of how particular DNS servers handle junk inputs. (I spent some time trying to create a second more-focused test that would sidestep the DNS resolution, but this is not possible without more invasive changes to the internal infrastructure of `ToSocketAddrs` and what not. It is not worth it.)
2020-03-06fix various typosMatthias Krüger-1/+1
2020-03-02Don't convert Results to Options just for matching.Matthias Krüger-1/+1
2020-02-29simplify boolean expressionsMatthias Krüger-1/+1
2020-01-29Document remaining undocumented `From` implementations for IPsLeSeulArtichaut-0/+72
2020-01-09Rollup merge of #67966 - popzxc:core-std-matches, r=CentrilMazdak Farrokhzad-16/+4
Use matches macro in libcore and libstd This PR replaces matches like ```rust match var { value => true, _ => false, } ``` with use of `matches!` macro. r? @Centril
2020-01-08Use matches macro in libcore and libstdIgor Aleksanov-16/+4
2020-01-06Removed module usage.Strømberg-1/+0
2020-01-06Missing module std in example.Strømberg-1/+1
2019-12-26Implement padding for IpAddr without heap allocDario Gonzalez-13/+80
2019-12-24Deprecate Error::description for realDavid Tolnay-0/+2
`description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This commit: - adds #[rustc_deprecated(since = "1.41.0")] to Error::description; - moves description (and cause, which is also deprecated) below the source and backtrace methods in the Error trait; - reduces documentation of description and cause to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call description; - removes the description function of all *currently unstable* Error impls in the standard library; - marks #[allow(deprecated)] the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of description in example code and the compiler.
2019-12-22Format the worldMark Rousskov-215/+278
2019-12-19Rollup merge of #67321 - lzutao:htons, r=dtolnayMazdak Farrokhzad-22/+11
make htons const fn This may partially help #67315.
2019-12-18Propagate cfg bootstrapMark Rousskov-4/+4
2019-12-15make htons const fnLzu Tao-22/+11
2019-12-14Delete flaky test net::tcp::tests::fast_rebindDavid Tolnay-15/+0
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-0/+4
functions with a `const` modifier
2019-12-06Remove boxed closures in address parser.Markus Reiter-19/+4
2019-11-29Format libstd with rustfmtDavid Tolnay-212/+294
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-11-13Fix broken links in Ipv4Addr::is_benchmarking docsBenjamin Sago-2/+2
2019-11-10Rollup merge of #66058 - mjptree:patch-2, r=kennytmYuki Okushi-1/+1
Correct deprecated `is_global` IPv6 documentation This method does currently not return false for the `site_local` unicast address space. The documentation of the `is_unicast_global` method on lines 1352 - 1382 suggests that this is intentional as the site-local prefix must no longer be supported in new implementations, thus the documentation can safely be updated to reflect that information. If not so, either the `is_unicast_global` method should be updated to exclude the unicast site-local address space, or the `is_global` method itself.
2019-11-09Update src/libstd/net/ip.rs mjptree-1/+1
I assumed some sort of Oxford-comma case here, bit have to admit English is not my first language. Co-Authored-By: kennytm <kennytm@gmail.com>
2019-11-03 Correct deprecated `is_global` IPv6 documentationmjptree-1/+1
This method does currently not return false for the `site_local` unicast address space. The documentation of the `is_unicast_global` method on lines 1352 - 1382 suggests that this is intentional as the site-local prefix must no longer be supported in new implementations, thus the documentation can safely be updated to reflect that information. If not so, either the `is_unicast_global` method should be updated to exclude the unicast site-local address space, or the `is_global` method itself.
2019-11-02Correct error in documentation for Ipv4Addr methodmjptree-1/+1
Correct statement in doctests on line 539 of `is_global` method of the `Ipv4Addr` object, which falsely attributed the tests to the broadcast address.
2019-10-20Remove leading :: from paths in doc examplesMikko Rantanen-1/+1
2019-10-05Rollup merge of #64728 - messense:udp-peer-addr, r=dtolnayTyler Mandry-3/+1
Stabilize UdpSocket::peer_addr Fixes #59127
2019-10-01Remove unneeded `fn main` blocks from docsLzu Tao-146/+108
2019-09-26Update src/libstd/net/udp.rsmessense-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-09-24Stabilize UdpSocket::peer_addrmessense-3/+1
2019-08-22VxWorks ignores the SO_SNDTIMEO socket option (this is long-standingSalim Nasser-2/+4
behavior), so skip the following tests: net::tcp::tests::timeouts net::udp::tests::timeouts
2019-07-18Fix typo in src/libstd/net/udp.rs doc commentMartin Indra-2/+2
Affect is usually used as a verb, effect as a verb.
2019-06-01Auto merge of #60145 - little-dude:ip2, r=alexcrichtonbors-163/+781
std::net: Ipv4Addr and Ipv6Addr improvements Picking this up again from my previous PR: https://github.com/rust-lang/rust/pull/56050 Related to: https://github.com/rust-lang/rust/issues/27709 Fixes: https://github.com/rust-lang/rust/issues/57558 - add `add Ipv4Addr::is_reserved()` - [X] implementation - [X] tests - add `Ipv6Addr::is_unicast_link_local_strict()` and update `Ipv6Addr::is_unicast_link_local()` documentation - [X] implementation - [X] test - add `Ipv4Addr::is_benchmarking()` - [X] implementation - [X] test - add `Ipv4Addr::is_ietf_protocol_assignment()` - [X] implementation - [X] test - add `Ipv4Addr::is_shared()` - [X] implementation - [x] test - fix `Ipv4Addr:is_global()` - [X] implementation - [x] test - [X] refactor the tests for IP properties. This makes the tests more verbose, but using macros have two advantages: - it will now be easier to add tests for all the new methods - we get clear error messages when a test is failing. For instance: ``` ---- net::ip::tests::ip_properties stdout ---- thread '<unnamed>' panicked at 'assertion failed: !ip!("fec0::").is_global()', src/libstd/net/ip.rs:2036:9 ``` Whereas previously it was something like ``` thread '<unnamed>' panicked at 'assertion failed: `(left == right)` left: `true`, right: `false`', libstd/net/ip.rs:1948:13 ``` ----------------------- # Ongoing discussions: ## Should `Ipv4Addr::is_global()` return `true` or `false` for reserved addresses? Reserved addresses are addresses that are matched by `Ipv4Addr::is_reserved()`. @the8472 [pointed out](https://github.com/rust-lang/rust/pull/60145#issuecomment-485458319) that [RFC 4291](https://tools.ietf.org/html/rfc4291#section-2.4) says IPv6 reserved addresses should be considered global: ``` Future specifications may redefine one or more sub-ranges of the Global Unicast space for other purposes, but unless and until that happens, implementations must treat all addresses that do not start with any of the above-listed prefixes as Global Unicast addresses. ``` We could extrapolate that this should also be the case for IPv4. However, it seems that [IANA considers them non global](https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml) (see [my comment](https://github.com/rust-lang/rust/pull/60145#issuecomment-485713270)) ### Final decision There seems to be a consensus that reserved addresses have a different meaning for IPv4 and IPv6 ([comment1](https://github.com/rust-lang/rust/pull/60145#issuecomment-485963789) [comment2](https://github.com/rust-lang/rust/pull/60145#issuecomment-485944582), so we can consider that RFC4291 does not apply to IPv4, and that reserved IPv4 addresses are _not_ global. ## Should `Ipv6Addr::is_unicast_site_local()` exist? @pusateri [noted](https://github.com/rust-lang/rust/pull/60145#issuecomment-485507515) that site-local addresses have been deprecated for a while by [RFC 3879](https://tools.ietf.org/html/rfc3879) and new implementations _must not_ support them. However, since this method is stable, removing does not seem possible. This kind of situation is covered by the RFC which stated that existing implementation _may_ continue supporting site-local addresses. ### Final decision Let's keep this method. It is stable already, and the RFC explicitly states that existing implementation may remain. --------- Note: I'll be AFK from April 27th to May 11th. Anyone should feel free to pick this up if the PR hasn't been merged by then. Sorry for dragging that for so long already.
2019-05-20Rollup merge of #60511 - taiki-e:libstd-intra-doc, r=Dylan-DPCMazdak Farrokhzad-0/+13
Fix intra-doc link resolution failure on re-exporting libstd Currently, re-exporting libstd items as below will [occur a lot of failures](https://gist.github.com/taiki-e/e33e0e8631ef47f65a74a3b69f456366). ```rust pub use std::*; ``` Until the underlying issue (#56922) fixed, we can fix that so they don't propagate to downstream crates. Related: https://github.com/rust-lang/rust/pull/56941 (That PR fixed failures that occur when re-exporting from libcore to libstd.) r? @QuietMisdreavus
2019-05-13Remove bitrig support from rustMarcel Hellwig-6/+6
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-0/+13
2019-04-27Stabilized vectored IOSteven Fackler-8/+8
This renames `std::io::IoVec` to `std::io::IoSlice` and `std::io::IoVecMut` to `std::io::IoSliceMut`, and stabilizes `std::io::IoSlice`, `std::io::IoSliceMut`, `std::io::Read::read_vectored`, and `std::io::Write::write_vectored`. Closes #58452
2019-04-23std::net: tests for Ipv4addr::is_shared()Corentin Henry-0/+15
2019-04-23std::net: add warning in Ipv4addr::is_reserved() documentationCorentin Henry-0/+7
See @the8472 comment's on Github: https://github.com/rust-lang/rust/pull/60145#issuecomment-485424229 > I don't think is_reserved including ranges marked for future use is > a good idea since those future uses may be realized at at some point > and then old software with is_reserved filters may have false > positives. This is not a hypothetical concern, such issues have been > encountered before when IANA assigned previously reserved /8 address > blocks.
2019-04-23std::net: add warning in Ipv6Addr::is_unicast_site_local() docCorentin Henry-0/+8
site-local addresses are deprecated, so we should warn users about it.
2019-04-22std::net: tests for Ipv4addr::is_reserved()Corentin Henry-0/+15
Also add tests to IpAddr for make sure these addresses are not global or multicast.
2019-04-22std::net: tests for Ipv4addr::is_ietf_protocol_assignment()Corentin Henry-0/+16
Also add tests to IpAddr to make sure these addresses are not global.
2019-04-22std::net: tests for Ipv4addr::is_benchmarking()Corentin Henry-16/+30
also add test to Ipaddr, making sure that these addresses are not global.
2019-04-22std::net: tests for Ipv6addr::is_unicast_link_local{_strict}()Corentin Henry-20/+49
2019-04-22std::net: fix tests for site-local ipv6 addressesCorentin Henry-2/+2
Ipv6Addr::is_unicast_global() now returns `true` for unicast site local addresses, since they are deprecated.
2019-04-22std::net: fix Ipv4addr::is_global() testsCorentin Henry-4/+4
Ipv4addr::is_global() previously considered 0/8 was global, but has now been fixed, so these tests needed to be fixed as well.
2019-04-22std::net: use macros to test ip propertiesCorentin Henry-143/+381
2019-04-22std::net: fix documentation markdownCorentin Henry-3/+5