about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2018-04-15Deprecate Read::chars and char::decode_utf8Simon Sapin-1/+17
Per FCP: * https://github.com/rust-lang/rust/issues/27802#issuecomment-377537778 * https://github.com/rust-lang/rust/issues/33906#issuecomment-377534308
2018-04-05Stabilize take_set_limitThayne McCombs-2/+1
Fixes #42781
2018-04-05Rollup merge of #49594 - mbrubeck:docs, r=steveklabnikkennytm-0/+22
Add some performance guidance to std::fs and std::io docs Adds more documentation about performance to various "read" functions in `fs` and `io`, and to `BufReader`/`BufWriter`, with the goal of helping developers choose the best option for a given task.
2018-04-03Add performance notes to BufReader/BufWriter docsMatt Brubeck-0/+12
2018-04-03Cross-reference fs::read functions from io::Read docsMatt Brubeck-0/+10
2018-04-02Fix typoRolf van de Krol-1/+1
2018-03-28Auto merge of #49357 - frewsxcv:frewsxcv-termination-doc-examples, ↵bors-473/+472
r=GuillaumeGomez Remove hidden `foo` functions from doc examples; use `Termination` trait. Fixes https://github.com/rust-lang/rust/issues/49233. Easier to review with the white-space ignoring `?w=1` feature: https://github.com/rust-lang/rust/pull/49357/files?w=1
2018-03-28Remove hidden `foo` functions from doc examples; use `Termination` trait.Corey Farwell-473/+472
Fixes https://github.com/rust-lang/rust/issues/49233.
2018-03-27Remove TryFrom impls that might become conditionally-infallible with a ↵Simon Sapin-2/+18
portability lint https://github.com/rust-lang/rust/pull/49305#issuecomment-376293243
2018-03-18Add BufReader::bufferSteven Fackler-1/+29
This subsumes the need for an explicit is_empty function, and provides access to the buffered data itself which has been requested from time to time.
2018-03-01Fix a bug introduced in previous commitStjepan Glavina-2/+2
2018-02-28Remove thread_local_stateStjepan Glavina-20/+19
2018-02-28Stabilize LocalKey::try_withStjepan Glavina-1/+4
2018-02-19Add missing linkAndreas Streichardt-0/+2
2018-02-18Rollup merge of #48275 - matthiaskrgr:codespell, r=kennytm,varkorGuillaume Gomez-1/+1
fix more typos found by codespell.
2018-02-17fix more typos found by codespell.Matthias Krüger-1/+1
2018-02-17Rollup merge of #48234 - zombiezen:patch-1, r=steveklabnikGuillaume Gomez-2/+0
Remove "empty buffer" doc in read_until This appears copied from fill_buf, but the above paragraph already indicates that a lack of delimiter at the end is EOF.
2018-02-15Remove "empty buffer" doc in read_untilRoss Light-2/+0
This appears copied from fill_buf, but the above paragraph already indicates that a lack of delimiter at the end is EOF.
2018-02-10Correct a few stability attributesOliver Middleton-1/+1
2018-01-30std: use more portable error number in from_raw_os_error docsJames Cowgill-4/+4
On MIPS, error number 98 is not EADDRINUSE (it is EPROTOTYPE). To fix the resulting test failure this causes, use a more portable error number in the example documentation. EINVAL shold be more reliable because it was defined in the original Unix as 22 so hopefully most derivatives have defined it the same way.
2018-01-15Rollup merge of #47330 - bmusin:patch-2, r=shepmasterkennytm-4/+4
fix off-by-one error Fixes https://github.com/rust-lang/rust/issues/47325.
2018-01-15Rollup merge of #47120 - clarcharr:io_error_debug, r=dtolnaykennytm-8/+35
Better Debug impl for io::Error. This PR includes the below changes: 1. The former impl wrapped the entire thing in `Error { repr: ... }` which was unhelpful; this has been removed. 2. The `Os` variant of `io::Error` included the code and message, but not the kind; this has been fixed. 3. The `Custom` variant of `io::Error` included a `Custom(Custom { ... })`, which is now just `Custom { ... }`. Example of previous impl: ```rust Error { repr: Custom( Custom { kind: InvalidData, error: Error { repr: Os { code: 2, message: "no such file or directory" } } } ) } ``` Example of new impl: ```rust Custom { kind: InvalidData, error: Os { code: 2, kind: NotFound, message: "no such file or directory" } } ```
2018-01-14Auto merge of #46832 - Diggsey:bufread-cheaper-seek, r=alexcrichtonbors-0/+46
BufRead: Only flush the internal buffer if seeking outside of it. Fixes #31100 r? @dtolnay
2018-01-13Add note to documentationDiggory Blake-0/+4
2018-01-13Implement "seek_relative"Diggory Blake-0/+42
2018-01-13Better Debug impl for io::Error.Clar Charr-8/+35
2018-01-13fix off-by-one errorBulat Musin-4/+4
2018-01-10Auto merge of #46830 - Diggsey:cursor-vec-mut, r=alexcrichtonbors-32/+58
Implement `Write` for `Cursor<&mut Vec<T>>` Fixes #30132 r? @dtolnay (I'm just going through `feature-accepted` issues I swear 😛)
2018-01-08Add missing linksGuillaume Gomez-7/+14
2018-01-05Clarify appending behavior of 'io::Read::read_to_string()'.Sergio Benitez-1/+1
2018-01-02Document when LineWriter flushes; document errors for into_inner.Corey Farwell-0/+11
Fixes https://github.com/rust-lang/rust/issues/42468.
2017-12-22Rollup merge of #46898 - tspiteri:int-overflow-not-underflow, r=steveklabnikkennytm-1/+1
docs: do not call integer overflows as underflows In the API docs, integer overflow is sometimes called underflow. Underflow is really when the magnitude of a floating-point number is too small so the number underflows to subnormal or zero. With integers it is always overflow, even if the expected result is less than the minimum number that can be represented.
2017-12-21docs: do not call integer overflows as underflowsTrevor Spiteri-1/+1
2017-12-20Fix some rustdoc warningsGuillaume Gomez-2/+3
2017-12-18Implement `Write` for `Cursor<&mut Vec<T>>`Diggory Blake-32/+58
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-4/+3
2017-12-03Add a specialization of read_exact for Cursor.Kyle Huey-0/+25
The read_exact implementation for &[u8] is optimized and usually allows LLVM to reduce a read_exact call for small numbers of bytes to a bounds check and a register load instead of a generic memcpy. On a workload I have that decompresses, deserializes (via bincode), and processes some data, this leads to a 40% speedup by essentially eliminating the deserialization overhead entirely.
2017-11-26Rollup merge of #46224 - GuillaumeGomez:io-missing-link, r=QuietMisdreavuskennytm-2/+1
Remove invalid doc link r? @rust-lang/docs
2017-11-23Remove invalid doc linkGuillaume Gomez-2/+1
2017-11-22Rollup merge of #46050 - sunfishcode:read_to_end, r=sfacklerkennytm-6/+3
Optimize `read_to_end`. This patch makes `read_to_end` use Vec's memory-growth pattern rather than using a custom pattern. This has some interesting effects: - If memory is reserved up front, `read_to_end` can be faster, as it starts reading at the buffer size, rather than always starting at 32 bytes. This speeds up file reading by 2x in one of my use cases. - It can reduce the number of syscalls when reading large files. Previously, `read_to_end` would settle into a sequence of 8192-byte reads. With this patch, the read size follows Vec's allocation pattern. For example, on a 16MiB file, it can do 21 read syscalls instead of 2057. In simple benchmarks of large files though, overall speed is still dominated by the actual I/O. - A downside is that Read implementations that don't implement `initializer()` may see increased memory zeroing overhead. I benchmarked this on a variety of data sizes, with and without preallocated buffers. Most benchmarks see no difference, but reading a small/medium file with a pre-allocated buffer is faster.
2017-11-21Auto merge of #45039 - QuietMisdreavus:doc-spotlight, ↵bors-0/+2
r=GuillaumeGomez,QuietMisdreavus show in docs whether the return type of a function impls Iterator/Read/Write Closes #25928 This PR makes it so that when rustdoc documents a function, it checks the return type to see whether it implements a handful of specific traits. If so, it will print the impl and any associated types. Rather than doing this via a whitelist within rustdoc, i chose to do this by a new `#[doc]` attribute parameter, so things like `Future` could tap into this if desired. ### Known shortcomings ~~The printing of impls currently uses the `where` class over the whole thing to shrink the font size relative to the function definition itself. Naturally, when the impl has a where clause of its own, it gets shrunken even further:~~ (This is no longer a problem because the design changed and rendered this concern moot.) The lookup currently just looks at the top-level type, not looking inside things like Result or Option, which renders the spotlights on Read/Write a little less useful: <details><summary>`File::{open, create}` don't have spotlight info (pic of old design)</summary> ![image](https://user-images.githubusercontent.com/5217170/31209495-e59d027e-a950-11e7-9998-ceefceb71c07.png) </details> All three of the initially spotlighted traits are generically implemented on `&mut` references. Rustdoc currently treats a `&mut T` reference-to-a-generic as an impl on the reference primitive itself. `&mut Self` counts as a generic in the eyes of rustdoc. All this combines to create this lovely scene on `Iterator::by_ref`: <details><summary>`Iterator::by_ref` spotlights Iterator, Read, and Write (pic of old design)</summary> ![image](https://user-images.githubusercontent.com/5217170/31209554-50b271ca-a951-11e7-928b-4f83416c8681.png) </details>
2017-11-18Add doc for `Read`ing from `&str` and some related cleanupGarrett Berg-7/+27
2017-11-17spotlight Iterator/Read/Write impls on function return typesQuietMisdreavus-0/+2
2017-11-16Optimize `read_to_end`.Dan Gohman-6/+3
This patch makes `read_to_end` use Vec's memory-growth pattern rather than using a custom pattern. This has some interesting effects: - If memory is reserved up front, `read_to_end` can be faster, as it starts reading at the buffer size, rather than always starting at 32 bytes. This speeds up file reading by 2x in one of my use cases. - It can reduce the number of syscalls when reading large files. Previously, `read_to_end` would settle into a sequence of 8192-byte reads. With this patch, the read size follows Vec's allocation pattern. For example, on a 16MiB file, it can do 21 read syscalls instead of 2057. In simple benchmarks of large files though, overall speed is still dominated by the actual I/O. - A downside is that Read implementations that don't implement `initializer()` may see increased memory zeroing overhead. I benchmarked this on a variety of data sizes, with and without preallocated buffers. Most benchmarks see no difference, but reading a small/medium file with a pre-allocated buffer is faster.
2017-11-14Fixed several pulldown warnings when documenting libstd.kennytm-2/+2
2017-11-08std: Change how EBADF is handled in `sys`Alex Crichton-3/+1
This commit removes the reexport of `EBADF_ERR` as a constant from libstd's portability facade, instead opting for a platform-specific function that specifically queries an `io::Error`. Not all platforms may have a constant for this, so it makes the intent a little more clear that a code need not be supplied, just an answer to a query.
2017-11-06Auto merge of #45369 - fintelia:patch-1, r=BurntSushibors-0/+25
Implement is_empty() for BufReader Simple implementation of `is_empty` method for BufReader so it is possible to tell whether there is any data in its buffer. I didn't know correct stability annotation to place on the function. Presumably there is no reason to place this feature behind a feature flag, but I wasn't sure how to tag it as an unstable feature without that. CC: #45323
2017-11-01Rollup merge of #45664 - mbrubeck:docs, r=estebankkennytm-4/+5
Fix incorrect error type in Read::byte docs None
2017-10-31Fix incorrect error type in Read::byte docsMatt Brubeck-4/+5
2017-10-31Add a hint what `BufRead` functions do on EOFTobias Bucher-0/+4