about summary refs log tree commit diff
path: root/src/libstd/io/mod.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-2993/+0
2020-07-26Avoid writes without any data in `Write::write_all_vectored`Tomasz Miąsko-2/+5
Previously, when non-empty sequence of empty IoSlices have been provided to `Write::write_all_vectored`, the buffers would be written as is with `Write::write_vectored` and subsequently the return value `Ok(0)` would be misinterpreted as an error. Avoid writes without any data by advancing the buffers first. This matches the documented behaviour of `Write::write_all_vectored` and is analogous to what happens in `Write::write_all`.
2020-07-19Fix merge conflict with recent PRAlexis Bourget-90/+51
2020-07-19Fix small nit in the link to readAlexis Bourget-1/+1
2020-07-18Update src/libstd/io/mod.rsManish Goregaokar-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-07-18Use intra-doc links in std::ioManish Goregaokar-90/+51
2020-07-18Add a link to read in the read_exact doc about the guaranteesAlexis Bourget-1/+4
2020-07-16Revert "Remove spotlight usage"Manish Goregaokar-0/+2
This reverts commit 13c6d5819aae3c0de6a90e7f17ea967bf4487cbb.
2020-06-01Add a warning about infinite reading in read_(until|line)Alexis Bourget-0/+8
2020-05-09Better documentation for io::Read::read() return valueElinvynia-0/+5
2020-04-29Rollup merge of #71296 - ChiefMilesEdgeworth:fix_doc_wording, r=Dylan-DPCDylan DPC-2/+3
Change wording on read_vectored docs Closes #70154 I'm happy to work with others to make the wording on this more clear. I think what I have is an improvement but may not be the final wording.
2020-04-26Suppress file length check temporarilySteven Fackler-0/+1
Will clean up in a separate PR
2020-04-26Update nameSteven Fackler-4/+4
2020-04-26Add Read/Write::can_read/write_vectoredSteven Fackler-0/+26
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-04-18Change wording on read_vectored docsNathan Abel-2/+3
2020-04-07Put reference to write_vectored in quotes in docThomas de Zeeuw-1/+1
2020-04-06Improve io::Write::write_all_vectored docsThomas de Zeeuw-11/+17
Also adds some more tests with different length IoSlices.
2020-04-01Fix link to write_vectoredThomas de Zeeuw-1/+1
2020-04-01Use unspecified over undefined in io::Write::write_all_vectored docsThomas de Zeeuw-7/+9
2020-03-31Add io::Write::write_all_vectoredThomas de Zeeuw-1/+161
Similar to io::Write::write_all but uses io::Write::write_vectored instead.
2020-03-24spaces between braces really ruin readabilityWithout Boats-4/+4
2020-03-24correct rustc versionWithout Boats-2/+2
2020-03-24IoSlice/IoSliceMut should be Send and SyncWithout Boats-0/+12
2020-03-21Tweak wording for std::io::Read::read functionadrian5-1/+1
2020-03-14Rollup merge of #69403 - LeSeulArtichaut:copy-ioslice, r=sfacklerYuki Okushi-0/+1
Implement `Copy` for `IoSlice` Resolves #69395 r? @sfackler
2020-03-10Rollup merge of #69514 - GuillaumeGomez:remove-spotlight, r=kinnisonMazdak Farrokhzad-2/+0
Remove spotlight I had a few comments saying that this feature was at best misunderstood or not even used so I decided to organize a poll about on [twitter](https://twitter.com/imperioworld_/status/1232769353503956994). After 87 votes, the result is very clear: it's not useful. Considering the amount of code we have just to run it, I think it's definitely worth it to remove it. r? @kinnison cc @ollie27
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-2/+2
2020-02-27use char instead of &str for single char patternsMatthias Krüger-2/+2
2020-02-27Remove spotlight usageGuillaume Gomez-2/+0
2020-02-23Implement `Copy` for `IoSlice`LeSeulArtichaut-0/+1
2020-01-28Document that write_all will not call write if given an empty bufferJosh Triplett-0/+2
Some types of Write instances have a semantic meaning associated with writing an empty buffer, such as sending an empty packet. This works when calling `write` directly, and supplying an empty buffer. However, calling `write_all` on an empty buffer will simply never call `write`, because `write_all` assumes it has no work to do. Document this behavior, to help prospective users of datagram-packet-style Write instances.
2019-12-22Format the worldMark Rousskov-2/+1
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-1/+1
2019-12-05Simplify {IoSlice, IoSliceMut}::advance examples and testsTomasz Miąsko-29/+26
Remove unnecessary calls to `std::mem::replace` and make variables immutable.
2019-11-29Format libstd with rustfmtDavid Tolnay-79/+89
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-09-16Fix inconsistent link formattingIvan Tham-6/+6
2019-09-03Changed comment to better reflect std's exceptional situationDaniel Henry-Mantilla-4/+4
2019-09-03Added warning around code with reference to uninit bytesDaniel Henry-Mantilla-0/+8
2019-08-06avoid unnecessary reservations in std::io::Take::read_to_endJack O'Connor-8/+58
Prevously the `read_to_end` implementation for `std::io::Take` used its own `limit` as a cap on the `reservation_size`. However, that could still result in an over-allocation like this: 1. Call `reader.take(5).read_to_end(&mut vec)`. 2. `read_to_end_with_reservation` reserves 5 bytes and calls `read`. 3. `read` writes 5 bytes. 4. `read_to_end_with_reservation` reserves 5 bytes and calls `read`. 5. `read` writes 0 bytes. 6. The read loop ends with `vec` having length 5 and capacity 10. The reservation of 5 bytes was correct for the read at step 2 but unnecessary for the read at step 4. By that second read, `Take::limit` is 0, but the `read_to_end_with_reservation` loop is still using the same `reservation_size` it started with. Solve this by having `read_to_end_with_reservation` take a closure, which lets it get a fresh `reservation_size` for each read. This is an implementation detail which doesn't affect any public API.
2019-08-03Add {IoSlice, IoSliceMut}::advanceThomas de Zeeuw-1/+199
2019-08-01Rollup merge of #62644 - arnottcr:std_io-doc, r=steveklabnikPietro Albini-1/+1
simplify std::io::Write::write rustdoc The std::io::Write::write method currensly suggests consumers guaranteed that `0 <= n <= buf.len()`, for `Ok(n)`, however `n` is of type `usize` causing the compiler to emit a warning: ``` warning: comparison is useless due to type limits --> lib.rs:6:18 | 6 | Ok(n) => 0 <= n && n <= output.len(), | ^^^^^^ | = note: #[warn(unused_comparisons)] on by default ``` This PR removes the suggestion to check `0 <= n` since it is moot. r? @steveklabnik
2019-07-28Rollup merge of #62806 - mati865:clippy, r=TimNNMazdak Farrokhzad-2/+2
Fix few Clippy warnings
2019-07-21read: fix doc commentRalf Jung-2/+2
2019-07-18Fix clippy::len_zero warningsMateusz Mikuła-2/+2
2019-07-13simplify std::io::Write::write rustdocColin Arnott-1/+1
The std::io::Write::write method currensly suggests consumers guaranteed that `0 <= n <= buf.len()`, for `Ok(n)`, however `n` is of type `usize` causing the compiler to emit a warning: ``` warning: comparison is useless due to type limits --> lib.rs:6:18 | 6 | Ok(n) => 0 <= n && n <= output.len(), | ^^^^^^ | = note: #[warn(unused_comparisons)] on by default ``` This PR removes the suggestion to check `0 <= n` since it is moot. r? @steveklabnik
2019-07-04Fix a typo in Write::write_vectored docsPaweł Romanowski-1/+1
2019-06-25tweak wordingRalf Jung-3/+3
2019-06-24call out explicitly that general read needs to be called with an initialized ↵Ralf Jung-1/+10
buffer
2019-05-18Simplify BufRead doc example using NLLBrent Kerby-9/+4
2019-04-27Stabilized vectored IOSteven Fackler-31/+31
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