@@ -49,29 +49,89 @@ pub mod rustrt {
49
49
50
50
// FIXME (#2004): This is all buffered. We might need an unbuffered variant
51
51
// 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
+ */
52
67
pub enum SeekStyle { SeekSet , SeekEnd , SeekCur , }
53
68
54
69
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
+ */
56
77
pub trait Reader {
57
78
// FIXME (#2004): Seekable really should be orthogonal.
58
79
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.
61
80
// 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
+ */
62
94
fn read ( & self , bytes : & mut [ u8 ] , len : uint ) -> uint ;
63
95
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
+ */
65
105
fn read_byte ( & self ) -> int ;
66
106
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
+ */
68
114
fn eof ( & self ) -> bool ;
69
115
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
+ */
72
126
fn seek ( & self , position : int , style : SeekStyle ) ;
73
127
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
+ */
75
135
fn tell ( & self ) -> uint ;
76
136
}
77
137
0 commit comments