pub trait ReaderUtil { fn read_bytes(&self, len: uint) -> ~[u8]; fn read_until(&self, c: u8, include: bool) -> ~str; fn read_line(&self) -> ~str; fn read_chars(&self, n: uint) -> ~[char]; fn read_char(&self) -> char; fn read_c_str(&self) -> ~str; fn read_whole_stream(&self) -> ~[u8]; fn each_byte(&self, it: &fn(int) -> bool) -> bool; fn each_char(&self, it: &fn(char) -> bool) -> bool; fn each_line(&self, it: &fn(&str) -> bool) -> bool; fn read_lines(&self) -> ~[~str]; fn read_le_uint_n(&self, nbytes: uint) -> u64; fn read_le_int_n(&self, nbytes: uint) -> i64; fn read_be_uint_n(&self, nbytes: uint) -> u64; fn read_be_int_n(&self, nbytes: uint) -> i64; fn read_le_uint(&self) -> uint; fn read_le_int(&self) -> int; fn read_be_uint(&self) -> uint; fn read_be_int(&self) -> int; fn read_be_u64(&self) -> u64; fn read_be_u32(&self) -> u32; fn read_be_u16(&self) -> u16; fn read_be_i64(&self) -> i64; fn read_be_i32(&self) -> i32; fn read_be_i16(&self) -> i16; fn read_be_f64(&self) -> f64; fn read_be_f32(&self) -> f32; fn read_le_u64(&self) -> u64; fn read_le_u32(&self) -> u32; fn read_le_u16(&self) -> u16; fn read_le_i64(&self) -> i64; fn read_le_i32(&self) -> i32; fn read_le_i16(&self) -> i16; fn read_le_f64(&self) -> f64; fn read_le_f32(&self) -> f32; fn read_u8(&self) -> u8; fn read_i8(&self) -> i8; }
The ReaderUtil
trait is a home for many of the utility functions
a particular Reader should implement.
The default Reader
trait is focused entirely on bytes. ReaderUtil
is based
on higher-level concepts like 'chars' and 'lines.'
None right now.
fn read_bytes(&self, len: uint) -> ~[u8]
Reads len
number of bytes, and gives you a new vector back.
None right now.
fn read_until(&self, c: u8, include: bool) -> ~str
Reads up until a specific byte is seen or EOF.
The include
parameter specifies if the character should be included
in the returned string.
None right now.
fn read_line(&self) -> ~str
Reads up until the first '\n' or EOF.
The '\n' is not included in the result.
None right now.
fn read_chars(&self, n: uint) -> ~[char]
Reads n
chars.
Assumes that those chars are UTF-8 encoded.
The '\n' is not included in the result.
None right now.
fn read_char(&self) -> char
Reads a single UTF-8 encoded char.
None right now.
fn read_c_str(&self) -> ~str
Reads up until the first null byte or EOF.
The null byte is not returned.
None right now.
fn read_whole_stream(&self) -> ~[u8]
Reads all remaining data in the stream.
None right now.
fn each_byte(&self, it: &fn(int) -> bool) -> bool
Iterate over every byte until EOF or the iterator breaks.
None right now.
fn each_char(&self, it: &fn(char) -> bool) -> bool
Iterate over every char until EOF or the iterator breaks.
None right now.
fn each_line(&self, it: &fn(&str) -> bool) -> bool
Iterate over every line until EOF or the iterator breaks.
None right now.
fn read_lines(&self) -> ~[~str]
Reads all of the lines in the stream.
Returns a vector of those lines.
None right now.
fn read_le_uint_n(&self, nbytes: uint) -> u64
Reads n
little-endian unsigned integer bytes.
n
must be between 1 and 8, inclusive.
None right now.
fn read_le_int_n(&self, nbytes: uint) -> i64
Reads n
little-endian signed integer bytes.
n
must be between 1 and 8, inclusive.
None right now.
fn read_be_uint_n(&self, nbytes: uint) -> u64
Reads n
big-endian unsigned integer bytes.
n
must be between 1 and 8, inclusive.
None right now.
fn read_be_int_n(&self, nbytes: uint) -> i64
Reads n
big-endian signed integer bytes.
n
must be between 1 and 8, inclusive.
None right now.
fn read_le_uint(&self) -> uint
Reads a little-endian unsigned integer.
The number of bytes returned is system-dependant.
None right now.
fn read_le_int(&self) -> int
Reads a little-endian integer.
The number of bytes returned is system-dependant.
None right now.
fn read_be_uint(&self) -> uint
Reads a big-endian unsigned integer.
The number of bytes returned is system-dependant.
None right now.
fn read_be_int(&self) -> int
Reads a big-endian integer.
The number of bytes returned is system-dependant.
None right now.
fn read_be_u64(&self) -> u64
Reads a big-endian u64
.
u64
s are 8 bytes long.
None right now.
fn read_be_u32(&self) -> u32
Reads a big-endian u32
.
u32
s are 4 bytes long.
None right now.
fn read_be_u16(&self) -> u16
Reads a big-endian u16
.
u16
s are 2 bytes long.
None right now.
fn read_be_i64(&self) -> i64
Reads a big-endian i64
.
i64
s are 8 bytes long.
None right now.
fn read_be_i32(&self) -> i32
Reads a big-endian i32
.
i32
s are 4 bytes long.
None right now.
fn read_be_i16(&self) -> i16
Reads a big-endian i16
.
i16
s are 2 bytes long.
None right now.
fn read_be_f64(&self) -> f64
Reads a big-endian f64
.
f64
s are 8 byte, IEEE754 double-precision floating point numbers.
None right now.
fn read_be_f32(&self) -> f32
Reads a big-endian f32
.
f32
s are 4 byte, IEEE754 single-precision floating point numbers.
None right now.
fn read_le_u64(&self) -> u64
Reads a little-endian u64
.
u64
s are 8 bytes long.
None right now.
fn read_le_u32(&self) -> u32
Reads a little-endian u32
.
u32
s are 4 bytes long.
None right now.
fn read_le_u16(&self) -> u16
Reads a little-endian u16
.
u16
s are 2 bytes long.
None right now.
fn read_le_i64(&self) -> i64
Reads a little-endian i64
.
i64
s are 8 bytes long.
None right now.
fn read_le_i32(&self) -> i32
Reads a little-endian i32
.
i32
s are 4 bytes long.
None right now.
fn read_le_i16(&self) -> i16
Reads a little-endian i16
.
i16
s are 2 bytes long.
None right now.
fn read_le_f64(&self) -> f64
Reads a little-endian f64
.
f64
s are 8 byte, IEEE754 double-precision floating point numbers.
None right now.
fn read_le_f32(&self) -> f32
Reads a little-endian f32
.
f32
s are 4 byte, IEEE754 single-precision floating point numbers.
None right now.
fn read_u8(&self) -> u8
Read a u8.
u8
s are 1 byte.
None right now.
fn read_i8(&self) -> i8
Read an i8.
i8
s are 1 byte.
None right now.
impl<T: Reader> ReaderUtil for T
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
).