about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2015-03-17Ignore stdio mutex poison stateSteven Fackler-3/+3
Nothing inside of the read/write interface itself can panic, so any poison must have been the result of user code which the lock isn't protecting.
2015-03-18Avoid metadata bloat by using trait FixedSizeArrayVadim Petrochenkov-20/+7
2015-03-18Fixed-size byte string literals (RFC 339)Vadim Petrochenkov-2/+19
2015-03-17Rollup merge of #23432 - mzabaluev:io-into-inner-doc, r=alexcrichtonManish Goregaokar-14/+15
Resolves #23386.
2015-03-17Rollup merge of #23415 - alexcrichton:stabilize-flush, r=aturonManish Goregaokar-1/+1
The [associated RFC][rfc] for possibly splitting out `flush` has been closed and as a result there are no more blockers for stabilizing this method, so this commit marks the method as such. [rfc]: https://github.com/rust-lang/rfcs/pull/950
2015-03-17std::io::buffered: Don't use 'flush' in documentation of into_innerMikhail Zabaluev-14/+15
The word 'flush' may be misinterpreted as if `flush` is called on the underlying writer, which is not the case.
2015-03-16impl<T> *const T, impl<T> *mut TJorge Aparicio-0/+1
2015-03-16impl<T> [T]Jorge Aparicio-0/+3
2015-03-16impl strJorge Aparicio-0/+3
2015-03-16std: Stabilize the Write::flush methodAlex Crichton-1/+1
The [associated RFC][rfc] for possibly splitting out `flush` has been closed and as a result there are no more blockers for stabilizing this method, so this commit marks the method as such. [rfc]: https://github.com/rust-lang/rfcs/pull/950
2015-03-15Auto merge of #23206 - nagisa:print-io, r=alexcrichtonbors-7/+49
r? @alexcrichton or @aturon This still needs to somehow figure out how to avoid unstable warnings arising from the use of unstable functions. I tried to use `#[allow_internal_unstable]` but it still spits out warnings as far as I can see. @huonw (I think you implemented it) does `#[allow_internal_unstable]` not work for some reason or am I using it incorrectly?
2015-03-15Rollup merge of #23379 - kballard:tweak-stdio-docs-no-raw-constructors, ↵Manish Goregaokar-18/+9
r=alexcrichton `std::io` does not currently expose the `stdin_raw`, `stdout_raw`, or `stderr_raw` functions. According to the current plans for stdio (see rust-lang/rfcs#517), raw access will likely be provided using the platform-specific `std::os::{unix,windows}` modules. At the moment we don't expose any way to do this. As such, delete all mention of the `*_raw` functions from the `stdin`/`stdout`/`stderr` function documentation. While we're at it, remove a few `pub`s from items that aren't exposed. This is done just to lessen the confusion experienced by anyone who looks at the source in an attempt to find the `*_raw` functions.
2015-03-14Remove incorrect references to _raw stdio functionsKevin Ballard-18/+9
std::io does not currently expose the stdin_raw, stdout_raw, or stderr_raw functions. According to the current plans for stdio (see RFC #517), raw access will likely be provided using the platform-specific std::os::{unix,windows} modules. At the moment we don't expose any way to do this. As such, delete all mention of the _raw functions from the stdin/stdout/stderr function documentation. While we're at it, remove a few `pub`s from items that aren't exposed. This is done just to lessen the confusion experienced by anyone who looks at the source in an attempt to find the _raw functions.
2015-03-14Stop recommending old_io in the module doc for std::ioKevin Ballard-4/+0
Now that `old_io` is deprecated and `std::io` is stable, we should stop recommending the use of `old_io` in the module documentation.
2015-03-15Use new io in print and println macrosesSimonas Kazlauskas-7/+49
2015-03-13Fallout of std::old_io deprecationAlex Crichton-12/+38
2015-03-12std: Stabilize the `io` moduleAlex Crichton-83/+198
The new `std::io` module has had some time to bake now, and this commit stabilizes its functionality. There are still portions of the module which remain unstable, and below contains a summart of the actions taken. This commit also deprecates the entire contents of the `old_io` module in a blanket fashion. All APIs should now have a reasonable replacement in the new I/O modules. Stable APIs: * `std::io` (the name) * `std::io::prelude` (the name) * `Read` * `Read::read` * `Read::{read_to_end, read_to_string}` after being modified to return a `usize` for the number of bytes read. * `Write` * `Write::write` * `Write::{write_all, write_fmt}` * `BufRead` * `BufRead::{fill_buf, consume}` * `BufRead::{read_line, read_until}` after being modified to return a `usize` for the number of bytes read. * `BufReader` * `BufReader::{new, with_capacity}` * `BufReader::{get_ref, get_mut, into_inner}` * `{Read,BufRead} for BufReader` * `BufWriter` * `BufWriter::{new, with_capacity}` * `BufWriter::{get_ref, get_mut, into_inner}` * `Write for BufWriter` * `IntoInnerError` * `IntoInnerError::{error, into_inner}` * `{Error,Display} for IntoInnerError` * `LineWriter` * `LineWriter::{new, with_capacity}` - `with_capacity` was added * `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added) * `Write for LineWriter` * `BufStream` * `BufStream::{new, with_capacities}` * `BufStream::{get_ref, get_mut, into_inner}` * `{BufRead,Read,Write} for BufStream` * `stdin` * `Stdin` * `Stdin::lock` * `Stdin::read_line` - added method * `StdinLock` * `Read for Stdin` * `{Read,BufRead} for StdinLock` * `stdout` * `Stdout` * `Stdout::lock` * `StdoutLock` * `Write for Stdout` * `Write for StdoutLock` * `stderr` * `Stderr` * `Stderr::lock` * `StderrLock` * `Write for Stderr` * `Write for StderrLock` * `io::Result` * `io::Error` * `io::Error::last_os_error` * `{Display, Error} for Error` Unstable APIs: (reasons can be found in the commit itself) * `Write::flush` * `Seek` * `ErrorKind` * `Error::new` * `Error::from_os_error` * `Error::kind` Deprecated APIs * `Error::description` - available via the `Error` trait * `Error::detail` - available via the `Display` implementation * `thread::Builder::{stdout, stderr}` Changes in functionality: * `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing backtraces has migrated to `std::io`. * The `ReadExt`, `WriteExt`, and `BufReadExt` extension traits were all removed by folding functionality into the corresponding trait. [breaking-change]
2015-03-06rollup merge of #23087: nagisa/std-undeadlockAlex Crichton-3/+0
Being a person who somehow has taken a liking to premature optimisation, my knee-jerk reaction to locking in std handles was preamble resembling following snippet: let stdout = stdout(); let lstdout = stdout.lock(); let stdin = stdin(); let lstdin = stdin.lock(); and then reading from the locked handle like this: let mut letter = [0; 1]; lstdin.read(&mut letter).unwrap(); As it is now this code will deadlock because the `read` method attempts to lock stdout as well! r? @alexcrichton --- Either way, I find flushing stdout when stdin is used debatable. I believe people who write prompts should take care to flush stdout when necessary themselves. Another idea: Would be cool if locks on std handles would be taken for a thread, rather than a handle, so given preamble (first code snippet) stdin.lock() or more generally stdin.read(…) worked fine. I.e. if more than a single lock are all taken inside the same thread, it would work, though not sure if our synchronisation primitives are expressive enough to make it possible.
2015-03-06Fix an easy to trigger deadlock in std::io::stdioSimonas Kazlauskas-3/+0
Being a person who somehow has taken a liking to premature optimisation, my knee-jerk reaction to locking in std handles was preamble resembling following snippet: let stdout = stdout(); let lstdout = stdout.lock(); let stdin = stdin(); let lstdin = stdin.lock(); and then reading from the locked handle like this: let mut letter = [0; 1]; lstdin.read(&mut letter).unwrap(); As it is now this code will deadlock because the `read` method attempts to lock stdout as well!
2015-03-06Rollup merge of #23010 - alexcrichton:deprecate-some-old-io, r=aturonManish Goregaokar-18/+115
The new `io` module has had some time to bake and this commit stabilizes some of the utilities associated with it. This commit also deprecates a number of `std::old_io::util` functions and structures. These items are now `#[stable]` * `Cursor` * `Cursor::{new, into_inner, get_ref, get_mut, position, set_position}` * Implementations of I/O traits for `Cursor<T>` * Delegating implementations of I/O traits for references and `Box` pointers * Implementations of I/O traits for primitives like slices and `Vec<T>` * `ReadExt::bytes` * `Bytes` (and impls) * `ReadExt::chain` * `Chain` (and impls) * `ReadExt::take` (and impls) * `BufReadExt::lines` * `Lines` (and impls) * `io::copy` * `io::{empty, Empty}` (and impls) * `io::{sink, Sink}` (and impls) * `io::{repeat, Repeat}` (and impls) These items remain `#[unstable]` * Core I/O traits. These may want a little bit more time to bake along with the commonly used methods like `read_to_end`. * `BufReadExt::split` - this function may be renamed to not conflict with `SliceExt::split`. * `Error` - there are a number of questions about its representation, `ErrorKind`, and usability. These items are now `#[deprecated]` in `old_io` * `LimitReader` - use `take` instead * `NullWriter` - use `io::sink` instead * `ZeroReader` - use `io::repeat` instead * `NullReader` - use `io::empty` instead * `MultiWriter` - use `broadcast` instead * `ChainedReader` - use `chain` instead * `TeeReader` - use `tee` instead * `copy` - use `io::copy` instead [breaking-change]
2015-03-05Remove integer suffixes where the types in compiled code are identical.Eduard Burtescu-9/+9
2015-03-04std: Stabilize portions of the `io` moduleAlex Crichton-18/+115
The new `io` module has had some time to bake and this commit stabilizes some of the utilities associated with it. This commit also deprecates a number of `std::old_io::util` functions and structures. These items are now `#[stable]` * `Cursor` * `Cursor::{new, into_inner, get_ref, get_mut, position, set_position}` * Implementations of I/O traits for `Cursor<T>` * Delegating implementations of I/O traits for references and `Box` pointers * Implementations of I/O traits for primitives like slices and `Vec<T>` * `ReadExt::bytes` * `Bytes` (and impls) * `ReadExt::chain` * `Chain` (and impls) * `ReadExt::take` (and impls) * `BufReadExt::lines` * `Lines` (and impls) * `io::copy` * `io::{empty, Empty}` (and impls) * `io::{sink, Sink}` (and impls) * `io::{repeat, Repeat}` (and impls) These items remain `#[unstable]` * Core I/O traits. These may want a little bit more time to bake along with the commonly used methods like `read_to_end`. * `BufReadExt::split` - this function may be renamed to not conflict with `SliceExt::split`. * `Error` - there are a number of questions about its representation, `ErrorKind`, and usability. These items are now `#[deprecated]` in `old_io` * `LimitReader` - use `take` instead * `NullWriter` - use `io::sink` instead * `ZeroReader` - use `io::repeat` instead * `NullReader` - use `io::empty` instead * `MultiWriter` - use `broadcast` instead * `ChainedReader` - use `chain` instead * `TeeReader` - use `tee` instead * `copy` - use `io::copy` instead [breaking-change]
2015-03-04Auto merge of #22920 - tshepang:remove-some-warnings, r=huonwbors-1/+1
2015-03-01remove some compiler warningsTshepang Lekhonkhobe-1/+1
2015-02-28std: Implement stdio for `std::io`Alex Crichton-0/+389
This is an implementation of RFC 899 and adds stdio functionality to the new `std::io` module. Details of the API can be found on the RFC, but from a high level: * `io::{stdin, stdout, stderr}` constructors are now available. There are also `*_raw` variants for unbuffered and unlocked access. * All handles are globally shared (excluding raw variants). * The stderr handle is no longer buffered. * All handles can be explicitly locked (excluding the raw variants). The `print!` and `println!` machinery has not yet been hooked up to these streams just yet. The `std::fmt::output` module has also not yet been implemented as part of this commit.
2015-02-26remove some compiler warningsTshepang Lekhonkhobe-6/+6
2015-02-25Rollup merge of #22729 - alexcrichton:ptr-stabilization, r=aturonManish Goregaokar-3/+3
Specifically, the following actions were takend: * The `copy_memory` and `copy_nonoverlapping_memory` functions to drop the `_memory` suffix (as it's implied by the functionality). Both functions are now marked as `#[stable]`. * The `set_memory` function was renamed to `write_bytes` and is now stable. * The `zero_memory` function is now deprecated in favor of `write_bytes` directly. * The `Unique` pointer type is now behind its own feature gate called `unique` to facilitate future stabilization. [breaking-change]
2015-02-24std: Stabilize some `ptr` functionsAlex Crichton-3/+3
Specifically, the following actions were taken: * The `copy_memory` and `copy_nonoverlapping_memory` functions to drop the `_memory` suffix (as it's implied by the functionality). Both functions are now marked as `#[stable]`. * The `set_memory` function was renamed to `write_bytes` and is now stable. * The `zero_memory` function is now deprecated in favor of `write_bytes` directly. * The `Unique` pointer type is now behind its own feature gate called `unique` to facilitate future stabilization. * All type parameters now are `T: ?Sized` wherever possible and new clauses were added to the `offset` functions to require that the type is sized. [breaking-change]
2015-02-25Rollup merge of #22778 - mzabaluev:leftover-lifetime, r=alexcrichtonManish Goregaokar-1/+1
2015-02-24std::io::BufReader: remove leftover lifetime parameter on get_ref()Mikhail Zabaluev-1/+1
2015-02-24Rollup merge of #22428 - erickt:io-wrappers, r=aturonManish Goregaokar-1/+36
Also includes some minor optimizations to the Vec and slice writers to remove the unnecessary loop.
2015-02-23Rollup merge of #22640 - sfackler:fix-take, r=alexcrichtonManish Goregaokar-0/+35
We can't call into the inner reader for a 0-byte read because that may end up blocking or returning an error. r? @alexcrichton
2015-02-21Implement BufRead for TakeSteven Fackler-0/+15
2015-02-22Rollup merge of #22567 - Gankro:unstable, r=alexcrichtonManish Goregaokar-8/+7
* Adds features and allows * Removes unused muts, unused imports, dead code * Migrates some deprecated code to new io/env * Changes std::num::uint/int to be re-exports of std::num::usize/isize libcollections, liballoc, and libcoretest no longer warn during testing. libstd warns much less, though there's some dangly bits that weren't obvious fixes. In particular, how to only supress deprecated warnings in specific submodules of std.
2015-02-21Fix io::Take behavior with limit 0Steven Fackler-0/+20
We can't call into the inner reader for a 0-byte read because that may end up blocking or returning an error.
2015-02-21Fix typo in std::io unstable reasonJake Goulding-1/+1
2015-02-20try to reduce bajillion warningsAlexis-8/+7
2015-02-19std: Update the std::io adaptors to proxy all methodsErick Tryzelaar-1/+36
2015-02-18Replace all uses of `&foo[]` with `&foo[..]` en masse.Niko Matsakis-9/+9
2015-02-17Rollup merge of #22311 - lfairy:consistent-fmt, r=alexcrichtonManish Goregaokar-2/+2
This brings it in line with its namesake in `std::io`. [breaking-change] r? @aturon
2015-02-16Make io::Seek docs less prescriptiveSteven Fackler-3/+2
2015-02-14Rename `fmt::Writer` to `fmt::Write`Chris Wong-2/+2
This brings it in line with its namesake in `std::io`. [breaking-change]
2015-02-10Auto merge of #21936 - alexcrichton:fsv2, r=aturonbors-0/+1
This commit is an implementation of [RFC 739][rfc] which adds a new `std::fs` module to the standard library. This module provides much of the same functionality as `std::old_io::fs` but it has many tweaked APIs as well as uses the new `std::path` module. [rfc]: https://github.com/rust-lang/rfcs/pull/739
2015-02-09std: Add a new `fs` moduleAlex Crichton-0/+1
This commit is an implementation of [RFC 739][rfc] which adds a new `std::fs` module to the standard library. This module provides much of the same functionality as `std::old_io::fs` but it has many tweaked APIs as well as uses the new `std::path` module. [rfc]: https://github.com/rust-lang/rfcs/pull/739
2015-02-06Rollup merge of #21926 - mzabaluev:raw-lifetime, r=alexcrichtonManish Goregaokar-3/+2
New functions, `slice::from_raw_parts` and `slice::from_raw_parts_mut`, are added to implement the lifetime convention as agreed in rust-lang/rfcs#556. The functions `slice::from_raw_buf` and `slice::from_raw_mut_buf` are left deprecated for the time being. Holding back on changing the signature of `std::ffi::c_str_to_bytes` as consensus in rust-lang/rfcs#592 is building to replace it with a composition of other functions. Contribution to #21923.
2015-02-05Replace one more slice::from_raw_mut_buf added with new ioMikhail Zabaluev-3/+2
2015-02-04Fix for misspelled comments.Joseph Crail-2/+2
The spelling corrections were made in both documentation comments and regular comments.
2015-02-03std: Add `io` module againAlex Crichton-0/+2483
This commit is an implementation of [RFC 576][rfc] which adds back the `std::io` module to the standard library. No functionality in `std::old_io` has been deprecated just yet, and the new `std::io` module is behind the same `io` feature gate. [rfc]: https://github.com/rust-lang/rfcs/pull/576 A good bit of functionality was copied over from `std::old_io`, but many tweaks were required for the new method signatures. Behavior such as precisely when buffered objects call to the underlying object may have been tweaked slightly in the transition. All implementations were audited to use composition wherever possible. For example the custom `pos` and `cap` cursors in `BufReader` were removed in favor of just using `Cursor<Vec<u8>>`. A few liberties were taken during this implementation which were not explicitly spelled out in the RFC: * The old `LineBufferedWriter` is now named `LineWriter` * The internal representation of `Error` now favors OS error codes (a 0-allocation path) and contains a `Box` for extra semantic data. * The io prelude currently reexports `Seek` as `NewSeek` to prevent conflicts with the real prelude reexport of `old_io::Seek` * The `chars` method was moved from `BufReadExt` to `ReadExt`. * The `chars` iterator returns a custom error with a variant that explains that the data was not valid UTF-8.
2015-01-26std: Rename io to old_ioAlex Crichton-12800/+0
In preparation for the I/O rejuvination of the standard library, this commit renames the current `io` module to `old_io` in order to make room for the new I/O modules. It is expected that the I/O RFCs will land incrementally over time instead of all at once, and this provides a fresh clean path for new modules to enter into as well as guaranteeing that all old infrastructure will remain in place for some time. As each `old_io` module is replaced it will be deprecated in-place for new structures in `std::{io, fs, net}` (as appropriate). This commit does *not* leave a reexport of `old_io as io` as the deprecation lint does not currently warn on this form of use. This is quite a large breaking change for all imports in existing code, but all functionality is retained precisely as-is and path statements simply need to be renamed from `io` to `old_io`. [breaking-change]
2015-01-21More test fixes and rebase conflictsAlex Crichton-1/+1