summary refs log tree commit diff
path: root/src/libstd/io/stdio.rs
AgeCommit message (Collapse)AuthorLines
2014-03-27Fix fallout of removing default boundsAlex Crichton-9/+12
This is all purely fallout of getting the previous commit to compile.
2014-03-20auto merge of #12980 : cmr/rust/overhaul-stdio, r=thestingerbors-1/+7
this comes from a discussion on IRC where the split between stdin and stdout seemed unnatural, and the fact that reading on stdin won't flush stdout, which is unlike every other language (including C's stdio).
2014-03-20rename std::vec -> std::sliceDaniel Micay-1/+1
Closes #12702
2014-03-19std: io: flush stdout on stdin read from ttyCorey Richardson-1/+7
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-6/+6
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-03-01std: Switch stdout/stderr to buffered by defaultAlex Crichton-5/+29
Similarly to #12422 which made stdin buffered by default, this commit makes the output streams also buffered by default. Now that buffered writers will flush their contents when they are dropped, I don't believe that there's no reason why the output shouldn't be buffered by default, which is what you want in 90% of cases. As with stdin, there are new stdout_raw() and stderr_raw() functions to get unbuffered streams to stdout/stderr.
2014-02-23Closes #12386. Removed 'pub mod' doc-comments in std::io's mod.rs file. ↵zslayton-5/+5
Added summary doc-comments to test.rs, util.rs and stdio.rs.
2014-02-20Return a buffered stdin by default.Alex Crichton-3/+16
One of the most common ways to use the stdin stream is to read it line by line for a small program. In order to facilitate this common usage pattern, this commit changes the stdin() function to return a BufferedReader by default. A new `stdin_raw()` method was added to get access to the raw unbuffered stream. I have not changed the stdout or stderr methods because they are currently unable to flush in their destructor, but #12403 should have just fixed that.
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-4/+4
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-03std: Fixing all documentationAlex Crichton-7/+8
* Stop referencing io_error * Start changing "Failure" sections to "Error" sections * Update all doc examples to work.
2014-02-03std: Fix tests with io_error usageAlex Crichton-2/+2
2014-02-03std: Remove io::io_errorAlex Crichton-47/+29
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-4/+4
2014-01-17Tweak the interface of std::ioAlex Crichton-2/+1
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered)
2014-01-09Remove eof() from io::ReaderAlex Crichton-2/+0
2014-01-07std: Fill in all missing importsAlex Crichton-0/+3
Fallout from the previous commits
2014-01-07auto merge of #11353 : alexcrichton/rust/improve-logging, r=brsonbors-27/+105
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-06Support arbitrary stdout/stderr/logger handlesAlex Crichton-27/+105
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-06Remove some unnecessary type castsFlorian Hahn-1/+1
Conflicts: src/librustc/middle/lint.rs
2013-12-25Test fixes and rebase conflictsAlex Crichton-2/+1
* vec::raw::to_ptr is gone * Pausible => Pausable * Removing @ * Calling the main task "<main>" * Removing unused imports * Removing unused mut * Bringing some libextra tests up to date * Allowing compiletest to work at stage0 * Fixing the bootstrap-from-c rmake tests * assert => rtassert in a few cases * printing to stderr instead of stdout in fail!()
2013-12-24std: Get stdtest all passing againAlex Crichton-15/+2
This commit brings the library up-to-date in order to get all tests passing again
2013-12-24std: Handle prints with literally no contextAlex Crichton-1/+11
Printing is an incredibly useful debugging utility, and it's not much help if your debugging prints just trigger an obscure abort when you need them most. In order to handle this case, forcibly fall back to a libc::write implementation of printing whenever a local task is not available. Note that this is *not* a 1:1 fallback. All 1:1 rust tasks will still have a local Task that it can go through (and stdio will be created through the local IO factory), this is only a fallback for "no context" rust code (such as that setting up the context).
2013-12-24std: Expose that LocalIo may not always be availableAlex Crichton-16/+10
It is not the case that all programs will always be able to acquire an instance of the LocalIo borrow, so this commit exposes this limitation by returning Option<LocalIo> from LocalIo::borrow(). At the same time, a helper method LocalIo::maybe_raise() has been added in order to encapsulate the functionality of raising on io_error if there is on local I/O available.
2013-12-10libstd: Remove `Cell` from the library.Patrick Walton-1/+1
2013-12-10librustuv: Change `with_local_io` to use RAII.Patrick Walton-6/+13
2013-12-04Don't dup the stdio file descriptors.Alex Crichton-12/+2
This is just an implementation detail of using libuv, so move the libuv-specific logic into librustuv.
2013-11-28Register new snapshotsAlex Crichton-4/+4
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-23/+15
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-2/+2
2013-11-19Implement more native file I/OAlex Crichton-1/+11
This implements a fair amount of the unimpl() functionality in io::native relating to filesystem operations. I've also modified all io::fs tests to run in both a native and uv environment (so everything is actually tested). There are a two bits of remaining functionality which I was unable to get working: * change_file_times on windows * lstat on windows I think that change_file_times may just need a better interface, but lstat has a large implementation in libuv which I didn't want to tackle trying to copy.
2013-11-13Implement native::IoFactoryAlex Crichton-9/+15
This commit re-organizes the io::native module slightly in order to have a working implementation of rtio::IoFactory which uses native implementations. The goal is to seamlessly multiplex among libuv/native implementations wherever necessary. Right now most of the native I/O is unimplemented, but we have existing bindings for file descriptors and processes which have been hooked up. What this means is that you can now invoke println!() from libstd with no local task, no local scheduler, and even without libuv. There's still plenty of work to do on the native I/O factory, but this is the first steps into making it an official portion of the standard library. I don't expect anyone to reach into io::native directly, but rather only std::io primitives will be used. Each std::io interface seamlessly falls back onto the native I/O implementation if the local scheduler doesn't have a libuv one (hurray trait ojects!)
2013-11-11Move std::rt::io to std::ioAlex Crichton-0/+321