about summary refs log tree commit diff
path: root/library/std/src/net/tcp.rs
AgeCommit message (Collapse)AuthorLines
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-1/+9
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-01-31Replace unwrap with ? in TcpListener docDaniel Chmielewski-1/+1
2022-07-02Bump std::net::Incoming FusedIterator impl to Rust 1.64David Tolnay-1/+1
2022-05-23Implement `FusedIterator` for `std::net::[Into]Incoming`Chayim Refael Friedman-0/+7
They never return `None`, so they trivially fulfill the contract.
2022-04-14Remove use of `#[rustc_deprecated]`Jacob Pratt-8/+2
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-5/+5
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-02-01Fix incorrect panic message in exampleTheVoid-1/+1
2021-11-02read_bufDrMeepster-13/+1
2021-10-30Add #[must_use] to remaining std functions (A-N)John Kugelman-0/+1
2021-10-10Add #[must_use] to conversions that move selfJohn Kugelman-0/+1
2021-09-17Rollup merge of #88339 - piegamesde:master, r=joshtriplettYuki Okushi-0/+51
Add TcpListener::into_incoming and IntoIncoming The `incoming` method is really useful, however for some use cases the borrow this introduces is needlessly restricting. Thus, an owned variant is added. r? ``@joshtriplett``
2021-08-30add `TcpStream::set_linger` and `TcpStream::linger`ibraheemdev-0/+47
2021-08-26Add TcpListener::into_incoming and IntoIncomingpiegames-0/+51
The `incoming` method is really useful, however for some use cases the borrow this introduces is needlessly restricting. Thus, an owned variant is added.
2021-08-20Auto merge of #87329 - sunfishcode:sunfishcode/io-safety, r=joshtriplettbors-0/+12
I/O safety. Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: <https://github.com/rust-lang/rust/issues/87074> RFC: <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md> Highlights: - The doc comments at the top of library/std/src/os/unix/io/mod.rs and library/std/src/os/windows/io/mod.rs - The new types and traits in library/std/src/os/unix/io/fd.rs and library/std/src/os/windows/io/handle.rs - The removal of the `RawHandle` struct the Windows impl, which had the same name as the `RawHandle` type alias, and its functionality is now folded into `Handle`. Managing five levels of wrapping (File wraps sys::fs::File wraps sys::fs::FileDesc wraps OwnedFd wraps RawFd, etc.) made for a fair amount of churn and verbose as/into/from sequences in some places. I've managed to simplify some of them, but I'm open to ideas here. r? `@joshtriplett`
2021-08-19Add comments about impls for File, TcpStream, ChildStdin, etc.Dan Gohman-0/+12
2021-08-08## ContextRichard Schneeman-7/+14
While going through the "The Rust Programming Language" book (Klabnik & Nichols), the TCP server example directs us to use TcpListener::incoming. I was curious how I could pass this value to a function (before reading ahead in the book), so I looked up the docs to determine the signature. When I opened the docs, I found https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming, which didn't mention TcpStream anywhere in the example. Eventually, I clicked on https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.accept in the docs (after clicking a few other locations first), and was able to surmise that the value contained TcpStream. ## Opportunity While this type is mentioned several times in this doc, I feel that someone should be able to fully use the results of the TcpListner::incoming iterator based solely on the docs of just this method. ## Implementation I took the code from the top-level TcpListener https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming and blended it with the existing docs for TcpListener::incoming https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming. It does make the example a little longer, and it also introduces a little duplication. It also gives the reader the type signatures they need to move on to the next step. ## Additional considerations I noticed that in this doc, `handle_connection` and `handle_client` are both used to accept a TcpStream in the docs on this page. I want to standardize on one function name convention, so readers don't accidentally think two different concepts are being referenced. I didn't want to cram do too much in one PR, I can update this PR to make that change, or I could send another PR (if you would like). First attempted contribution to Rust (and I'm also still very new, hence reading through the rust book for the first time)! Would you please let me know what you think?
2020-11-22Drop support for cloudabi targetsLzu Tao-1/+1
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-866/+4
Also doing fmt inplace as requested.
2020-08-15Move to intra doc links in std::netAlexis Bourget-62/+22
2020-07-27mv std libs to library/mark-0/+1844