Basic input/output
fd_t
FileFlag
SeekStyle
WriterType
BytesReader
BytesWriter
FILERes
FdRes
Reader
- The raw underlying reader traitReaderUtil
- Generic utility functions defined on readers.Writer
- The raw underlying writer traitWriterUtil
- Generic utility functions defined on writers.of Reader for @Reader
of ReaderUtil for T where <T: Reader>
of Reader for *libc::FILE
of Reader for Wrapper<R, C> where <R: Reader, C>
of Drop for FILERes
of Reader for BytesReader<'self> where <'self>
of ::core::cmp::Eq for WriterType
of Writer for @Writer
of Writer for Wrapper<W, C> where <W: Writer, C>
of Writer for *libc::FILE
of Writer for fd_t
of Drop for FdRes
of WriterUtil for T where <T: Writer>
of Writer for BytesWriter
BytesWriter
FILERes
FILE_reader
FILE_writer
FdRes
buffered_file_writer
fd_writer
file_reader
file_writer
mk_file_writer
print
println
read_whole_file
read_whole_file_str
seek_in_buf
stderr
stdin
stdout
u64_from_be_bytes
u64_to_be_bytes
u64_to_le_bytes
with_bytes_reader
with_bytes_writer
with_str_reader
with_str_writer
io::fsync
io::rustrt
fd_t
type fd_t = c_int
FileFlag
Append
Create
Truncate
NoFlag
SeekStyle
SeekSet
SeekEnd
SeekCur
WriterType
Screen
File
BytesReader
pub struct BytesReader<'self> {
bytes: &'self [u8],
mut pos: uint,
}
BytesWriter
pub struct BytesWriter {
mut bytes: ~[u8],
mut pos: uint,
}
FILERes
pub struct FILERes {
f: *libc::FILE,
}
FdRes
pub struct FdRes {
fd: fd_t,
}
Reader
The raw underlying reader trait. All readers must implement this.
read
fn read(&self, bytes: &mut [u8], len: uint) -> uint
Read up to len bytes (or EOF) and put them into bytes (which must be at least len bytes long). Return number of bytes read.
read_byte
fn read_byte(&self) -> int
Read a single byte, returning a negative value for EOF or read error.
eof
fn eof(&self) -> bool
Return whether the stream is currently at EOF position.
seek
fn seek(&self, position: int, style: SeekStyle)
Move the current position within the stream. The second parameter determines the position that the first parameter is relative to.
tell
fn tell(&self) -> uint
Return the current position within the stream.
ReaderUtil
Generic utility functions defined on readers.
read_bytes
fn read_bytes(&self, len: uint) -> ~[u8]
Read len bytes into a new vec.
read_until
fn read_until(&self, c: char, include: bool) -> ~str
Read up until a specified character (which is optionally included) or EOF.
read_line
fn read_line(&self) -> ~str
Read up until the first '\n' char (which is not returned), or EOF.
read_chars
fn read_chars(&self, n: uint) -> ~[char]
Read n utf-8 encoded chars.
read_char
fn read_char(&self) -> char
Read a single utf-8 encoded char.
read_c_str
fn read_c_str(&self) -> ~str
Read up until the first null byte (which is not returned), or EOF.
read_whole_stream
fn read_whole_stream(&self) -> ~[u8]
Read all the data remaining in the stream in one go.
each_byte
fn each_byte(&self, it: &fn(int) -> bool)
Iterate over every byte until the iterator breaks or EOF.
each_char
fn each_char(&self, it: &fn(char) -> bool)
Iterate over every char until the iterator breaks or EOF.
each_line
fn each_line(&self, it: &fn(&str) -> bool)
Iterate over every line until the iterator breaks or EOF.
read_lines
fn read_lines(&self) -> ~[~str]
Read all the lines of the file into a vector.
read_le_uint_n
fn read_le_uint_n(&self, nbytes: uint) -> u64
Read n (between 1 and 8) little-endian unsigned integer bytes.
read_le_int_n
fn read_le_int_n(&self, nbytes: uint) -> i64
Read n (between 1 and 8) little-endian signed integer bytes.
read_be_uint_n
fn read_be_uint_n(&self, nbytes: uint) -> u64
Read n (between 1 and 8) big-endian unsigned integer bytes.
read_be_int_n
fn read_be_int_n(&self, nbytes: uint) -> i64
Read n (between 1 and 8) big-endian signed integer bytes.
read_le_uint
fn read_le_uint(&self) -> uint
Read a little-endian uint (number of bytes depends on system).
read_le_int
fn read_le_int(&self) -> int
Read a little-endian int (number of bytes depends on system).
read_be_uint
fn read_be_uint(&self) -> uint
Read a big-endian uint (number of bytes depends on system).
read_be_int
fn read_be_int(&self) -> int
Read a big-endian int (number of bytes depends on system).
read_be_u64
fn read_be_u64(&self) -> u64
Read a big-endian u64 (8 bytes).
read_be_u32
fn read_be_u32(&self) -> u32
Read a big-endian u32 (4 bytes).
read_be_u16
fn read_be_u16(&self) -> u16
Read a big-endian u16 (2 bytes).
read_be_i64
fn read_be_i64(&self) -> i64
Read a big-endian i64 (8 bytes).
read_be_i32
fn read_be_i32(&self) -> i32
Read a big-endian i32 (4 bytes).
read_be_i16
fn read_be_i16(&self) -> i16
Read a big-endian i16 (2 bytes).
read_be_f64
fn read_be_f64(&self) -> f64
Read a big-endian IEEE754 double-precision floating-point (8 bytes).
read_be_f32
fn read_be_f32(&self) -> f32
Read a big-endian IEEE754 single-precision floating-point (4 bytes).
read_le_u64
fn read_le_u64(&self) -> u64
Read a little-endian u64 (8 bytes).
read_le_u32
fn read_le_u32(&self) -> u32
Read a little-endian u32 (4 bytes).
read_le_u16
fn read_le_u16(&self) -> u16
Read a little-endian u16 (2 bytes).
read_le_i64
fn read_le_i64(&self) -> i64
Read a litle-endian i64 (8 bytes).
read_le_i32
fn read_le_i32(&self) -> i32
Read a litle-endian i32 (4 bytes).
read_le_i16
fn read_le_i16(&self) -> i16
Read a litle-endian i16 (2 bytes).
read_le_f64
fn read_le_f64(&self) -> f64
Read a litten-endian IEEE754 double-precision floating-point (8 bytes).
read_le_f32
fn read_le_f32(&self) -> f32
Read a litten-endian IEEE754 single-precision floating-point (4 bytes).
read_u8
fn read_u8(&self) -> u8
Read a u8 (1 byte).
read_i8
fn read_i8(&self) -> i8
Read a i8 (1 byte).
Writer
The raw underlying writer trait. All writers must implement this.
write
fn write(&self, v: &const [u8])
Write all of the given bytes.
seek
fn seek(&self, int, SeekStyle)
Move the current position within the stream. The second parameter determines the position that the first parameter is relative to.
tell
fn tell(&self) -> uint
Return the current position within the stream.
flush
fn flush(&self) -> int
Flush the output buffer for this stream (if there is one).
get_type
fn get_type(&self) -> WriterType
Determine if this Writer is writing to a file or not.
WriterUtil
Generic utility functions defined on writers.
write_char
fn write_char(&self, ch: char)
Write a single utf-8 encoded char.
write_str
fn write_str(&self, s: &str)
Write every char in the given str, encoded as utf-8.
write_line
fn write_line(&self, s: &str)
Write the given str, as utf-8, followed by '\n'.
write_int
fn write_int(&self, n: int)
Write the result of passing n through int::to_str_bytes
.
write_uint
fn write_uint(&self, n: uint)
Write the result of passing n through uint::to_str_bytes
.
write_le_uint
fn write_le_uint(&self, n: uint)
Write a little-endian uint (number of bytes depends on system).
write_le_int
fn write_le_int(&self, n: int)
Write a little-endian int (number of bytes depends on system).
write_be_uint
fn write_be_uint(&self, n: uint)
Write a big-endian uint (number of bytes depends on system).
write_be_int
fn write_be_int(&self, n: int)
Write a big-endian int (number of bytes depends on system).
write_be_u64
fn write_be_u64(&self, n: u64)
Write a big-endian u64 (8 bytes).
write_be_u32
fn write_be_u32(&self, n: u32)
Write a big-endian u32 (4 bytes).
write_be_u16
fn write_be_u16(&self, n: u16)
Write a big-endian u16 (2 bytes).
write_be_i64
fn write_be_i64(&self, n: i64)
Write a big-endian i64 (8 bytes).
write_be_i32
fn write_be_i32(&self, n: i32)
Write a big-endian i32 (4 bytes).
write_be_i16
fn write_be_i16(&self, n: i16)
Write a big-endian i16 (2 bytes).
write_be_f64
fn write_be_f64(&self, f: f64)
Write a big-endian IEEE754 double-precision floating-point (8 bytes).
write_be_f32
fn write_be_f32(&self, f: f32)
Write a big-endian IEEE754 single-precision floating-point (4 bytes).
write_le_u64
fn write_le_u64(&self, n: u64)
Write a little-endian u64 (8 bytes).
write_le_u32
fn write_le_u32(&self, n: u32)
Write a little-endian u32 (4 bytes).
write_le_u16
fn write_le_u16(&self, n: u16)
Write a little-endian u16 (2 bytes).
write_le_i64
fn write_le_i64(&self, n: i64)
Write a little-endian i64 (8 bytes).
write_le_i32
fn write_le_i32(&self, n: i32)
Write a little-endian i32 (4 bytes).
write_le_i16
fn write_le_i16(&self, n: i16)
Write a little-endian i16 (2 bytes).
write_le_f64
fn write_le_f64(&self, f: f64)
Write a little-endian IEEE754 double-precision floating-point (8 bytes).
write_le_f32
fn write_le_f32(&self, f: f32)
Write a litten-endian IEEE754 single-precision floating-point (4 bytes).
write_u8
fn write_u8(&self, n: u8)
Write a u8 (1 byte).
write_i8
fn write_i8(&self, n: i8)
Write a i8 (1 byte).
Reader
for @Reader
read
fn read(&self, bytes: &mut [u8], len: uint) -> uint
read_byte
fn read_byte(&self) -> int
eof
fn eof(&self) -> bool
seek
fn seek(&self, position: int, style: SeekStyle)
tell
fn tell(&self) -> uint
ReaderUtil
for T
where <T: Reader>
read_bytes
fn read_bytes(&self, len: uint) -> ~[u8]
read_until
fn read_until(&self, c: char, include: bool) -> ~str
read_line
fn read_line(&self) -> ~str
read_chars
fn read_chars(&self, n: uint) -> ~[char]
read_char
fn read_char(&self) -> char
read_c_str
fn read_c_str(&self) -> ~str
read_whole_stream
fn read_whole_stream(&self) -> ~[u8]
each_byte
fn each_byte(&self, it: &fn(int) -> bool)
each_char
fn each_char(&self, it: &fn(char) -> bool)
each_line
fn each_line(&self, it: &fn(s: &str) -> bool)
read_lines
fn read_lines(&self) -> ~[~str]
read_le_uint_n
fn read_le_uint_n(&self, nbytes: uint) -> u64
read_le_int_n
fn read_le_int_n(&self, nbytes: uint) -> i64
read_be_uint_n
fn read_be_uint_n(&self, nbytes: uint) -> u64
read_be_int_n
fn read_be_int_n(&self, nbytes: uint) -> i64
read_le_uint
fn read_le_uint(&self) -> uint
read_le_int
fn read_le_int(&self) -> int
read_be_uint
fn read_be_uint(&self) -> uint
read_be_int
fn read_be_int(&self) -> int
read_be_u64
fn read_be_u64(&self) -> u64
read_be_u32
fn read_be_u32(&self) -> u32
read_be_u16
fn read_be_u16(&self) -> u16
read_be_i64
fn read_be_i64(&self) -> i64
read_be_i32
fn read_be_i32(&self) -> i32
read_be_i16
fn read_be_i16(&self) -> i16
read_be_f64
fn read_be_f64(&self) -> f64
read_be_f32
fn read_be_f32(&self) -> f32
read_le_u64
fn read_le_u64(&self) -> u64
read_le_u32
fn read_le_u32(&self) -> u32
read_le_u16
fn read_le_u16(&self) -> u16
read_le_i64
fn read_le_i64(&self) -> i64
read_le_i32
fn read_le_i32(&self) -> i32
read_le_i16
fn read_le_i16(&self) -> i16
read_le_f64
fn read_le_f64(&self) -> f64
read_le_f32
fn read_le_f32(&self) -> f32
read_u8
fn read_u8(&self) -> u8
read_i8
fn read_i8(&self) -> i8
Reader
for *libc::FILE
read
fn read(&self, bytes: &mut [u8], len: uint) -> uint
read_byte
fn read_byte(&self) -> int
eof
fn eof(&self) -> bool
seek
fn seek(&self, offset: int, whence: SeekStyle)
tell
fn tell(&self) -> uint
Reader
for Wrapper<R, C>
where <R: Reader, C>
read
fn read(&self, bytes: &mut [u8], len: uint) -> uint
read_byte
fn read_byte(&self) -> int
eof
fn eof(&self) -> bool
seek
fn seek(&self, off: int, whence: SeekStyle)
tell
fn tell(&self) -> uint
Drop
for FILERes
finalize
fn finalize(&self)
Reader
for BytesReader<'self>
where <'self>
read
fn read(&self, bytes: &mut [u8], len: uint) -> uint
read_byte
fn read_byte(&self) -> int
eof
fn eof(&self) -> bool
seek
fn seek(&self, offset: int, whence: SeekStyle)
tell
fn tell(&self) -> uint
::core::cmp::Eq
for WriterType
eq
fn eq(&self, __other: &WriterType) -> bool
ne
fn ne(&self, __other: &WriterType) -> bool
Writer
for @Writer
write
fn write(&self, v: &const [u8])
seek
fn seek(&self, a: int, b: SeekStyle)
tell
fn tell(&self) -> uint
flush
fn flush(&self) -> int
get_type
fn get_type(&self) -> WriterType
Writer
for Wrapper<W, C>
where <W: Writer, C>
write
fn write(&self, bs: &const [u8])
seek
fn seek(&self, off: int, style: SeekStyle)
tell
fn tell(&self) -> uint
flush
fn flush(&self) -> int
get_type
fn get_type(&self) -> WriterType
Writer
for *libc::FILE
write
fn write(&self, v: &const [u8])
seek
fn seek(&self, offset: int, whence: SeekStyle)
tell
fn tell(&self) -> uint
flush
fn flush(&self) -> int
get_type
fn get_type(&self) -> WriterType
Writer
for fd_t
write
fn write(&self, v: &const [u8])
seek
fn seek(&self, _offset: int, _whence: SeekStyle)
tell
fn tell(&self) -> uint
flush
fn flush(&self) -> int
get_type
fn get_type(&self) -> WriterType
Drop
for FdRes
finalize
fn finalize(&self)
WriterUtil
for T
where <T: Writer>
write_char
fn write_char(&self, ch: char)
write_str
fn write_str(&self, s: &str)
write_line
fn write_line(&self, s: &str)
write_int
fn write_int(&self, n: int)
write_uint
fn write_uint(&self, n: uint)
write_le_uint
fn write_le_uint(&self, n: uint)
write_le_int
fn write_le_int(&self, n: int)
write_be_uint
fn write_be_uint(&self, n: uint)
write_be_int
fn write_be_int(&self, n: int)
write_be_u64
fn write_be_u64(&self, n: u64)
write_be_u32
fn write_be_u32(&self, n: u32)
write_be_u16
fn write_be_u16(&self, n: u16)
write_be_i64
fn write_be_i64(&self, n: i64)
write_be_i32
fn write_be_i32(&self, n: i32)
write_be_i16
fn write_be_i16(&self, n: i16)
write_be_f64
fn write_be_f64(&self, f: f64)
write_be_f32
fn write_be_f32(&self, f: f32)
write_le_u64
fn write_le_u64(&self, n: u64)
write_le_u32
fn write_le_u32(&self, n: u32)
write_le_u16
fn write_le_u16(&self, n: u16)
write_le_i64
fn write_le_i64(&self, n: i64)
write_le_i32
fn write_le_i32(&self, n: i32)
write_le_i16
fn write_le_i16(&self, n: i16)
write_le_f64
fn write_le_f64(&self, f: f64)
write_le_f32
fn write_le_f32(&self, f: f32)
write_u8
fn write_u8(&self, n: u8)
write_i8
fn write_i8(&self, n: i8)
Writer
for BytesWriter
write
fn write(&self, v: &const [u8])
seek
fn seek(&self, offset: int, whence: SeekStyle)
tell
fn tell(&self) -> uint
flush
fn flush(&self) -> int
get_type
fn get_type(&self) -> WriterType
BytesWriter
fn BytesWriter() -> BytesWriter
FILERes
fn FILERes(f: *libc::FILE) -> FILERes
FILE_reader
fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader
FILE_writer
fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer
FdRes
fn FdRes(fd: fd_t) -> FdRes
buffered_file_writer
fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str>
fd_writer
fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer
file_reader
fn file_reader(path: &Path) -> Result<@Reader, ~str>
file_writer
fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<@Writer, ~str>
mk_file_writer
fn mk_file_writer(path: &Path, flags: &[FileFlag]) -> Result<@Writer, ~str>
print
fn print(s: &str)
println
fn println(s: &str)
read_whole_file
fn read_whole_file(file: &Path) -> Result<~[u8], ~str>
read_whole_file_str
fn read_whole_file_str(file: &Path) -> Result<~str, ~str>
seek_in_buf
fn seek_in_buf(offset: int, pos: uint, len: uint, whence: SeekStyle) -> uint
stderr
fn stderr() -> @Writer
stdin
fn stdin() -> @Reader
stdout
fn stdout() -> @Writer
u64_from_be_bytes
fn u64_from_be_bytes(data: &const [u8], start: uint, size: uint) -> u64
u64_to_be_bytes
fn u64_to_be_bytes<T>(n: u64, size: uint, f: &fn(v: &[u8]) -> T) -> T
u64_to_le_bytes
fn u64_to_le_bytes<T>(n: u64, size: uint, f: &fn(v: &[u8]) -> T) -> T
with_bytes_reader
fn with_bytes_reader<t>(bytes: &[u8], f: &fn(@Reader) -> t) -> t
with_bytes_writer
fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8]
with_str_reader
fn with_str_reader<T>(s: &str, f: &fn(@Reader) -> T) -> T
with_str_writer
fn with_str_writer(f: &fn(@Writer)) -> ~str