about summary refs log tree commit diff
path: root/library/std/src/io/util.rs
AgeCommit message (Collapse)AuthorLines
2021-09-25Apply 16 commits (squashed)Frank Steffahn-1/+1
---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::fmt ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::{rc, sync} ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::string ---------- Fix spacing for links inside code blocks in alloc::vec ---------- Fix spacing for links inside code blocks in core::option ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in core::result ---------- Fix spacing for links inside code blocks in core::{iter::{self, iterator}, stream::stream, poll} ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{fs, path} ---------- Fix spacing for links inside code blocks in std::{collections, time} ---------- Fix spacing for links inside code blocks in and make formatting of `&str`-like types consistent in std::ffi::{c_str, os_str} ---------- Fix spacing for links inside code blocks, and improve link tooltips in std::ffi ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{io::{self, buffered::{bufreader, bufwriter}, cursor, util}, net::{self, addr}} ---------- Fix typo in link to `into` for `OsString` docs ---------- Remove tooltips that will probably become redundant in the future ---------- Apply suggestions from code review Replacing `…std/primitive.reference.html` paths with just `reference` Co-authored-by: Joshua Nelson <github@jyn.dev> ---------- Also replace `…std/primitive.reference.html` paths with just `reference` in `core::pin`
2021-06-30impl Default, Copy, Clone for std::io::Sink and EmptyIan Jackson-0/+2
The omission of Sink: Default is causing me a slight inconvenience in a test harness. There seems little reason for this and Empty not to be Clone and Copy too. I have made all three of these insta-stable, because: AIUI Copycan only be derived, and I was not able to find any examples of how to unstably derive it. I think it is probably not possible. I hunted through the git history for precedent and found 79b8ad84c84481a43704213cd0948d2ba0ea63b4 Implement `Copy` for `IoSlice` https://github.com/rust-lang/rust/pull/69403 which was also insta-stable. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-24Use `#[non_exhaustive]` where appropriateJacob Pratt-8/+6
Due to the std/alloc split, it is not possible to make `alloc::collections::TryReserveError::AllocError` non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from `#[non_exhaustive]`.
2021-06-10Specialize `io::Bytes::size_hint` for more typesBenoît du Garreau-0/+13
2021-04-21Replace all `fmt.pad` with `debug_struct`Christiaan Dirkx-3/+3
2021-01-31Fix line length formatXavientois-1/+3
2021-01-31Add space for proper indentationXavientois-1/+1
2021-01-31Implement SizeHint trait for BufReader, Emtpy, and ChainXavientois-1/+7
2021-01-30impl Seek for Emptyoberien-1/+16
Fix #78029
2020-11-14Auto merge of #75272 - the8472:spec-copy, r=KodrAusbors-72/+1
specialize io::copy to use copy_file_range, splice or sendfile Fixes #74426. Also covers #60689 but only as an optimization instead of an official API. The specialization only covers std-owned structs so it should avoid the problems with #71091 Currently linux-only but it should be generalizable to other unix systems that have sendfile/sosplice and similar. There is a bit of optimization potential around the syscall count. Right now it may end up doing more syscalls than the naive copy loop when doing short (<8KiB) copies between file descriptors. The test case executes the following: ``` [pid 103776] statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=17, ...}) = 0 [pid 103776] write(4, "wxyz", 4) = 4 [pid 103776] write(4, "iklmn", 5) = 5 [pid 103776] copy_file_range(3, NULL, 4, NULL, 5, 0) = 5 ``` 0-1 `stat` calls to identify the source file type. 0 if the type can be inferred from the struct from which the FD was extracted 𝖬 `write` to drain the `BufReader`/`BufWriter` wrappers. only happen when buffers are present. 𝖬 ≾ number of wrappers present. If there is a write buffer it may absorb the read buffer contents first so only result in a single write. Vectored writes would also be an option but that would require more invasive changes to `BufWriter`. 𝖭 `copy_file_range`/`splice`/`sendfile` until file size, EOF or the byte limit from `Take` is reached. This should generally be *much* more efficient than the read-write loop and also have other benefits such as DMA offload or extent sharing. ## Benchmarks ``` OLD test io::tests::bench_file_to_file_copy ... bench: 21,002 ns/iter (+/- 750) = 6240 MB/s [ext4] test io::tests::bench_file_to_file_copy ... bench: 35,704 ns/iter (+/- 1,108) = 3671 MB/s [btrfs] test io::tests::bench_file_to_socket_copy ... bench: 57,002 ns/iter (+/- 4,205) = 2299 MB/s test io::tests::bench_socket_pipe_socket_copy ... bench: 142,640 ns/iter (+/- 77,851) = 918 MB/s NEW test io::tests::bench_file_to_file_copy ... bench: 14,745 ns/iter (+/- 519) = 8889 MB/s [ext4] test io::tests::bench_file_to_file_copy ... bench: 6,128 ns/iter (+/- 227) = 21389 MB/s [btrfs] test io::tests::bench_file_to_socket_copy ... bench: 13,767 ns/iter (+/- 3,767) = 9520 MB/s test io::tests::bench_socket_pipe_socket_copy ... bench: 26,471 ns/iter (+/- 6,412) = 4951 MB/s ```
2020-11-13specialize io::copy to use copy_file_range, splice or sendfileThe8472-72/+1
Currently it only applies to linux systems. It can be extended to make use of similar syscalls on other unix systems.
2020-11-06Add tracking issueBenoît du Garreau-3/+3
2020-11-06Make some std::io functions `const`Benoît du Garreau-3/+6
Includes: - io::Cursor::new - io::Cursor::get_ref - io::Cursor::position - io::empty - io::repeat - io::sink
2020-09-21Rollup merge of #76275 - FedericoPonzi:immutable-write-impl-73836, r=dtolnayecstatic-morse-0/+24
Implementation of Write for some immutable ref structs Fixes #73836
2020-09-21Updates stability attributes to the current nightly versionFederico Ponzi-1/+1
2020-09-03More implementations of Write for immutable refsFederico Ponzi-0/+24
Fixes #73836
2020-09-02Read: adjust a FIXME referenceRalf Jung-5/+8
2020-09-01Auto merge of #76047 - Dylan-DPC:rename/maybe, r=RalfJungbors-4/+4
rename get_{ref, mut} to assume_init_{ref,mut} in Maybeuninit References #63568 Rework with comments addressed from #66174 Have replaced most of the occurrences I've found, hopefully didn't miss out anything r? @RalfJung (thanks @danielhenrymantilla for the initial work on this)
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-49/+3
Also doing fmt inplace as requested.
2020-08-30update fixmesDPC-1/+1
2020-08-29rename get_{ref, mut} to assume_init_{ref,mut} in MaybeuninitDPC-3/+3
2020-08-18Move to intra doc links for std::ioAlexis Bourget-18/+15
2020-07-27mv std libs to library/mark-0/+308