Skip to content

Commit cb16cd9

Browse files
committed
auto merge of #5673 : steveklabnik/rust/improve_io_docs, r=catamorphism
When I submitted #5659, it apparently caused some test failures. Then, because I left it in my incoming rather than making a new branch, I deleted my commit. Let's try this again, this time, with its own branch so that I don't screw it up. r?
2 parents f357a03 + 86d5ce5 commit cb16cd9

File tree

1 file changed

+68
-8
lines changed

1 file changed

+68
-8
lines changed

src/libcore/io.rs

+68-8
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,89 @@ pub mod rustrt {
4949

5050
// FIXME (#2004): This is all buffered. We might need an unbuffered variant
5151
// as well
52+
/**
53+
* The SeekStyle enum describes the relationship between the position
54+
* we'd like to seek to from our current position. It's used as an argument
55+
* to the `seek` method defined on the `Reader` trait.
56+
*
57+
* There are three seek styles:
58+
*
59+
* 1. `SeekSet` means that the new position should become our position.
60+
* 2. `SeekCur` means that we should seek from the current position.
61+
* 3. `SeekEnd` means that we should seek from the end.
62+
*
63+
* # Examples
64+
*
65+
* None right now.
66+
*/
5267
pub enum SeekStyle { SeekSet, SeekEnd, SeekCur, }
5368

5469

55-
/// The raw underlying reader trait. All readers must implement this.
70+
/**
71+
* The core Reader trait. All readers must implement this trait.
72+
*
73+
* # Examples
74+
*
75+
* None right now.
76+
*/
5677
pub trait Reader {
5778
// FIXME (#2004): Seekable really should be orthogonal.
5879

59-
/// Read up to len bytes (or EOF) and put them into bytes (which
60-
/// must be at least len bytes long). Return number of bytes read.
6180
// FIXME (#2982): This should probably return an error.
81+
/**
82+
* Reads bytes and puts them into `bytes`. Returns the number of
83+
* bytes read.
84+
*
85+
* The number of bytes to be read is `len` or the end of the file,
86+
* whichever comes first.
87+
*
88+
* The buffer must be at least `len` bytes long.
89+
*
90+
* # Examples
91+
*
92+
* None right now.
93+
*/
6294
fn read(&self, bytes: &mut [u8], len: uint) -> uint;
6395

64-
/// Read a single byte, returning a negative value for EOF or read error.
96+
/**
97+
* Reads a single byte.
98+
*
99+
* In the case of an EOF or an error, returns a negative value.
100+
*
101+
* # Examples
102+
*
103+
* None right now.
104+
*/
65105
fn read_byte(&self) -> int;
66106

67-
/// Return whether the stream is currently at EOF position.
107+
/**
108+
* Returns a boolean value: are we currently at EOF?
109+
*
110+
* # Examples
111+
*
112+
* None right now.
113+
*/
68114
fn eof(&self) -> bool;
69115

70-
/// Move the current position within the stream. The second parameter
71-
/// determines the position that the first parameter is relative to.
116+
/**
117+
* Seek to a given `position` in the stream.
118+
*
119+
* Takes an optional SeekStyle, which affects how we seek from the
120+
* position. See `SeekStyle` docs for more details.
121+
*
122+
* # Examples
123+
*
124+
* None right now.
125+
*/
72126
fn seek(&self, position: int, style: SeekStyle);
73127

74-
/// Return the current position within the stream.
128+
/**
129+
* Returns the current position within the stream.
130+
*
131+
* # Examples
132+
*
133+
* None right now.
134+
*/
75135
fn tell(&self) -> uint;
76136
}
77137

0 commit comments

Comments
 (0)