pub trait Reader { fn read(&self, bytes: &mut [u8], len: uint) -> uint; fn read_byte(&self) -> int; fn eof(&self) -> bool; fn seek(&self, position: int, style: SeekStyle); fn tell(&self) -> uint; }
The core Reader trait. All readers must implement this trait.
None right now.
fn read(&self, bytes: &mut [u8], len: uint) -> uint
Reads bytes and puts them into bytes
, advancing the cursor. Returns the
number of bytes read.
The number of bytes to be read is len
or the end of the file,
whichever comes first.
The buffer must be at least len
bytes long.
read
is conceptually similar to C's fread
function.
None right now.
fn read_byte(&self) -> int
Reads a single byte, advancing the cursor.
In the case of an EOF or an error, returns a negative value.
read_byte
is conceptually similar to C's getc
function.
None right now.
fn eof(&self) -> bool
Returns a boolean value: are we currently at EOF?
Note that stream position may be already at the end-of-file point,
but eof
returns false until an attempt to read at that position.
eof
is conceptually similar to C's feof
function.
None right now.
fn seek(&self, position: int, style: SeekStyle)
Seek to a given position
in the stream.
Takes an optional SeekStyle, which affects how we seek from the
position. See SeekStyle
docs for more details.
seek
is conceptually similar to C's fseek
function.
None right now.
fn tell(&self) -> uint
Returns the current position within the stream.
tell
is conceptually similar to C's ftell
function.
None right now.
BytesReader
Wrapper<R, C>
impl Reader for @Reader
impl Reader for *FILE
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).