summary refs log tree commit diff
path: root/src/libstd/io/buffered.rs
AgeCommit message (Collapse)AuthorLines
2014-03-24auto merge of #13049 : alexcrichton/rust/io-fill, r=huonwbors-3/+3
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-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-3/+3
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-20rename std::vec -> std::sliceDaniel Micay-6/+6
Closes #12702
2014-03-12Update io iterators to produce IoResultsPalmer Cox-5/+5
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-06fix typos with with repeated words, just like this sentence.Kang Seonghoon-2/+2
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-21/+21
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-20Mass rename if_ok! to try!Alex Crichton-6/+6
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-20move extra::test to libtestLiigo Zhuang-1/+2
2014-02-14return value/use extra::test::black_box in benchmarkslpy-2/+2
2014-02-13Removed num::OrderableMichael Darakananda-2/+2
2014-02-09std::io: Add `Chars` iterator for Buffer.gifnksm-0/+10
Add `std::io::Chars` iterator and `Buffer#chars()` method
2014-02-03std: Fixing all documentationAlex Crichton-7/+6
* 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-50/+55
2014-02-03std: Remove io::io_errorAlex Crichton-37/+43
* 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-27Demote self to an (almost) regular argument and remove the env param.Eduard Burtescu-1/+1
Fixes #10667 and closes #10259.
2014-01-21[std::vec] Rename .shift_opt() to .shift(), drop the old .shift() behaviorSimon Sapin-1/+1
2014-01-17Tweak the interface of std::ioAlex Crichton-54/+64
* 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-25/+8
2014-01-08Remove the io::Decorator traitAlex Crichton-64/+80
This is just an unnecessary trait that no one's ever going to parameterize over and it's more useful to just define the methods directly on the types themselves. The implementors of this type almost always don't want inner_mut_ref() but they're forced to define it as well.
2014-01-08Robustly read remaining bytes in a characterAlex Crichton-1/+7
Closes #11372
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-1/+2
2014-01-04Don't allow newtype structs to be dereferenced. #6246Brian Anderson-5/+27
2013-12-23Add tests for 0-byte read propagation.Sébastien Paolacci-0/+28
The two `Some(0)' used to be `None' before the patch, a zero-byte long read exhausting a reader (and thereafter) still produce a `None'.
2013-12-16Make BufferedReader propagate 0-byte long reads.Sébastien Paolacci-3/+3
Could prevent callers from catching the situation and lead to e.g early iterator terminations (cf. `Reader::read_byte') since `None' is only to be returned only on EOF.
2013-12-15auto merge of #10984 : huonw/rust/clean-raw, r=cmrbors-4/+4
See commits for details.
2013-12-15Move std::{str,vec}::raw::set_len to an unsafe method on Owned{Vector,Str}.Huon Wilson-2/+2
2013-12-15std::vec: remove unnecessary count parameter on {bytes,Huon Wilson-2/+2
raw}::copy_memory. Slices carry their length with them, so we can just use that information.
2013-12-15std: fix spelling in docs.Huon Wilson-2/+2
2013-12-11std::io: Add Buffer.lines(), change .bytes() apiklutzy-0/+22
- `Buffer.lines()` returns `LineIterator` which yields line using `.read_line()`. - `Reader.bytes()` now takes `&mut self` instead of `self`. - `Reader.read_until()` swallows `EndOfFile`. This also affects `.read_line()`.
2013-11-30Fixes for BufferedWriter and LineBufferedWriterSteven Fackler-10/+28
BufferedWriter::inner flushes before returning the underlying writer. BufferedWriter::write no longer flushes the underlying writer. LineBufferedWriter::write flushes up to the *last* newline in the input string, not the first.
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-6/+6
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-19Implement more native file I/OAlex Crichton-1/+0
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-13Introduce an io::Buffer traitAlex Crichton-81/+26
This trait is meant to abstract whether a reader is actually implemented with an underlying buffer. For all readers which are implemented as such, we can efficiently implement things like read_char, read_line, read_until, etc. There are two required methods for managing the internal buffer, and otherwise read_line and friends can all become default methods. Closes #10334
2013-11-12io: benchmarks for creation of the various Buffered objectsCorey Richardson-0/+42
2013-11-11Move std::rt::io to std::ioAlex Crichton-0/+473