summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2014-03-30Removed deprecated functions `map` and `flat_map` for vectors and slices.Marvin Löbel-2/+3
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-9/+9
Closes #2569
2014-03-28syntax: Accept meta matchers in macrosAlex Crichton-3/+3
This removes the `attr` matcher and adds a `meta` matcher. The previous `attr` matcher is now ambiguous because it doesn't disambiguate whether it means inner attribute or outer attribute. The new behavior can still be achieved by taking an argument of the form `#[$foo:meta]` (the brackets are part of the macro pattern). Closes #13067
2014-03-28native: Use WNOHANG before signalingAlex Crichton-3/+26
It turns out that on linux, and possibly other platforms, child processes will continue to accept signals until they have been *reaped*. This means that once the child has exited, it will succeed to receive signals until waitpid() has been invoked on it. This is unfortunate behavior, and differs from what is seen on OSX and windows. This commit changes the behavior of Process::signal() to be the same across platforms, and updates the documentation of Process::kill() to note that when signaling a foreign process it may accept signals until reaped. Implementation-wise, this invokes waitpid() with WNOHANG before each signal to the child to ensure that if the child has exited that we will reap it. Other possibilities include installing a SIGCHLD signal handler, but at this time I believe that that's too complicated. Closes #13124
2014-03-27Fix fallout of removing default boundsAlex Crichton-28/+36
This is all purely fallout of getting the previous commit to compile.
2014-03-25std: Touch various I/O documentation blocksAlex Crichton-4/+30
These are mostly touchups from the previous commit.
2014-03-25libstd: Document the following modules:Patrick Walton-14/+128
* native::io * std::char * std::fmt * std::fmt::parse * std::io * std::io::extensions * std::io::net::ip * std::io::net::udp * std::io::net::unix * std::io::pipe * std::num * std::num::f32 * std::num::f64 * std::num::strconv * std::os
2014-03-24comm: Implement synchronous channelsAlex Crichton-2/+2
This commit contains an implementation of synchronous, bounded channels for Rust. This is an implementation of the proposal made last January [1]. These channels are built on mutexes, and currently focus on a working implementation rather than speed. Receivers for sync channels have select() implemented for them, but there is currently no implementation of select() for sync senders. Rust will continue to provide both synchronous and asynchronous channels as part of the standard distribution, there is no intent to remove asynchronous channels. This flavor of channels is meant to provide an alternative to asynchronous channels because like green tasks, asynchronous channels are not appropriate for all situations. [1] - https://mail.mozilla.org/pipermail/rust-dev/2014-January/007924.html
2014-03-24auto merge of #13049 : alexcrichton/rust/io-fill, r=huonwbors-7/+38
This method can be used to fill a byte slice of data entirely, and it's considered an error if any error happens before its entirely filled.
2014-03-23auto merge of #13096 : sstewartgallus/rust/cleanup-test-warnings, r=huonwbors-2/+2
2014-03-23This commit cleans up a few test warningsSteven Stewart-Gallus-2/+2
2014-03-22Some cleanup in std::io::bufferedSteven Fackler-15/+24
`Vec` is now used for the internal buffer instead of `~[]`. Some module level documentation somehow ended up attached to `BufferedReader` so I fixed that as well.
2014-03-22std: Add an I/O reader method to fill a bufferAlex Crichton-7/+38
I've found a common use case being to fill a slice (not an owned vector) completely with bytes. It's posible for short reads to happen, and if you're trying to get an exact number of bytes then this helper will be useful.
2014-03-22auto merge of #12907 : alexcrichton/rust/issue-12892, r=brsonbors-18/+19
These methods can be mistaken for general "read some bytes" utilities when they're actually only meant for reading an exact number of bytes. By renaming them it's much clearer about what they're doing without having to read the documentation. Closes #12892
2014-03-20std: Implement Clone/TotalEq for ProcessExitAlex Crichton-1/+2
It's useful for structures which use deriving(Clone, TotalEq), even though it's implicitly copyable. Closes #13047
2014-03-20std: Rename {push,read}_bytes to {push,read}_exactAlex Crichton-18/+19
These methods can be mistaken for general "read some bytes" utilities when they're actually only meant for reading an exact number of bytes. By renaming them it's much clearer about what they're doing without having to read the documentation. Closes #12892
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_ng -> std::vecDaniel Micay-1/+1
Closes #12771
2014-03-20rename std::vec -> std::sliceDaniel Micay-28/+28
Closes #12702
2014-03-19std: io: flush stdout on stdin read from ttyCorey Richardson-1/+7
2014-03-15log: Introduce liblog, the old std::loggingAlex Crichton-9/+4
This commit moves all logging out of the standard library into an external crate. This crate is the new crate which is responsible for all logging macros and logging implementation. A few reasons for this change are: * The crate map has always been a bit of a code smell among rust programs. It has difficulty being loaded on almost all platforms, and it's used almost exclusively for logging and only logging. Removing the crate map is one of the end goals of this movement. * The compiler has a fair bit of special support for logging. It has the __log_level() expression as well as generating a global word per module specifying the log level. This is unfairly favoring the built-in logging system, and is much better done purely in libraries instead of the compiler itself. * Initialization of logging is much easier to do if there is no reliance on a magical crate map being available to set module log levels. * If the logging library can be written outside of the standard library, there's no reason that it shouldn't be. It's likely that we're not going to build the highest quality logging library of all time, so third-party libraries should be able to provide just as high-quality logging systems as the default one provided in the rust distribution. With a migration such as this, the change does not come for free. There are some subtle changes in the behavior of liblog vs the previous logging macros: * The core change of this migration is that there is no longer a physical log-level per module. This concept is still emulated (it is quite useful), but there is now only a global log level, not a local one. This global log level is a reflection of the maximum of all log levels specified. The previously generated logging code looked like: if specified_level <= __module_log_level() { println!(...) } The newly generated code looks like: if specified_level <= ::log::LOG_LEVEL { if ::log::module_enabled(module_path!()) { println!(...) } } Notably, the first layer of checking is still intended to be "super fast" in that it's just a load of a global word and a compare. The second layer of checking is executed to determine if the current module does indeed have logging turned on. This means that if any module has a debug log level turned on, all modules with debug log levels get a little bit slower (they all do more expensive dynamic checks to determine if they're turned on or not). Semantically, this migration brings no change in this respect, but runtime-wise, this will have a perf impact on some code. * A `RUST_LOG=::help` directive will no longer print out a list of all modules that can be logged. This is because the crate map will no longer specify the log levels of all modules, so the list of modules is not known. Additionally, warnings can no longer be provided if a malformed logging directive was supplied. The new "hello world" for logging looks like: #[phase(syntax, link)] extern crate log; fn main() { debug!("Hello, world!"); }
2014-03-14extra: Put the nail in the coffin, delete libextraAlex Crichton-19/+103
This commit shreds all remnants of libextra from the compiler and standard distribution. Two modules, c_vec/tempfile, were moved into libstd after some cleanup, and the other modules were moved to separate crates as seen fit. Closes #8784 Closes #12413 Closes #12576
2014-03-13auto merge of #12855 : alexcrichton/rust/shutdown, r=brsonbors-0/+18
This is something that is plausibly useful, and is provided by libuv. This is not currently surfaced as part of the `TcpStream` type, but it may possibly appear in the future. For now only the raw functionality is provided through the Rtio objects.
2014-03-13io: Bind to shutdown() for TCP streamsAlex Crichton-0/+18
This is something that is plausibly useful, and is provided by libuv. This is not currently surfaced as part of the `TcpStream` type, but it may possibly appear in the future. For now only the raw functionality is provided through the Rtio objects.
2014-03-13auto merge of #12815 : alexcrichton/rust/chan-rename, r=brsonbors-288/+246
* 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-13std: Rename Chan/Port types and constructorAlex Crichton-288/+246
* 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-13auto merge of #12573 : lbonn/rust/unrecurs, r=alexcrichtonbors-11/+85
As mentioned in #6109, ```mkdir_recursive``` doesn't really need to use recursive calls, so here is an iterative version. The other points of the proposed overhaul (renaming and existing permissions) still need to be resolved. I also bundled an iterative ```rmdir_recursive```, for the same reason. Please do not hesitate to provide feedback on style as this is my first code change in rust.
2014-03-12auto merge of #12414 : DaGenix/rust/failing-iterator-wrappers, r=alexcrichtonbors-46/+53
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults. Fixes #12368
2014-03-12Update io iterators to produce IoResultsPalmer Cox-46/+53
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults. Fixes #12368
2014-03-12std: allow io::File* structs to be hashableErick Tryzelaar-1/+3
2014-03-12Remove remaining nolink usages.(fixes #12810)lpy-1/+0
2014-03-12doc: discuss try! in std::ioPeter Marheine-0/+34
2014-03-12Remove the dependence of std::io::test on rand.Huon Wilson-4/+11
This replaces it with a manual "task rng" using XorShift and a crappy seeding mechanism. Theoretically good enough for the purposes though (unique for tests).
2014-03-10fs: units tests for mkdir_recusive and rmdir_recursiveLaurent Bonnans-0/+26
The rmdir test is blocked by #12795 on windows.
2014-03-10fs: use an iterative algorithm for 'rmdir_recursive'Laurent Bonnans-8/+41
For now, the windows version uses stat, just as before. We should switch back to lstat as soon as #12795 is closed.
2014-03-10fs: use an iterative algorithm for 'mkdir_recursive'Laurent Bonnans-3/+18
as requested in #6109
2014-03-06fix typos with with repeated words, just like this sentence.Kang Seonghoon-4/+4
2014-03-04Rename struct fields with uppercase characters in their names to use lowercasePalmer Cox-4/+4
2014-03-04Rename all variables that have uppercase characters in their names to use ↵Palmer Cox-2/+2
only lowercase characters
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-03-01std: Flush when buffered writers are droppedAlex Crichton-14/+25
It's still not entirely clear what should happen if there was an error when flushing, but I'm deferring that decision to #12628. I believe that it's crucial for the usefulness of buffered writers to be able to flush on drop. It's just too easy to forget to flush them in small one-off use cases. cc #12628
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-38/+38
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-28std: Improve some I/O documentationAlex Crichton-33/+188
This lowers the #[allow(missing_doc)] directive into some of the lower modules which are less mature. Most I/O modules now require comprehensive documentation.
2014-02-27rustc: Use libnative for the compilerAlex Crichton-1/+1
The compiler itself doesn't necessarily need any features of green threading such as spawning tasks and lots of I/O, so libnative is slightly more appropriate for rustc to use itself. This should also help the rusti bot which is currently incompatible with libuv.
2014-02-27std: Small cleanup and test improvementAlex Crichton-150/+176
This weeds out a bunch of warnings building stdtest on windows, and it also adds a check! macro to the io::fs tests to help diagnose errors that are cropping up on windows platforms as well. cc #12516
2014-02-26auto merge of #12490 : zslayton/rust/doc-fix-12386, r=alexcrichtonbors-19/+9
Attn: @huonw Addresses #12386.
2014-02-25auto merge of #12522 : erickt/rust/hash, r=alexcrichtonbors-1/+0
This patch series does a couple things: * replaces manual `Hash` implementations with `#[deriving(Hash)]` * adds `Hash` back to `std::prelude` * minor cleanup of whitespace and variable names.
2014-02-24Remove std::from_str::FromStr from the preludeBrendan Zabarauskas-0/+1
2014-02-24std: minor whitespace cleanupErick Tryzelaar-1/+0
2014-02-24windows: Fix the test_exists unit testAlex Crichton-2/+5
Turns out the `timeout` command was exiting immediately because it didn't like its output piped. Instead use `ping` repeatedly to get a process that will sleep for awhile. cc #12516