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 ReaderUtil for T
of Reader for *libc::FILE
of Reader for {base: T, cleanup: C,}
of Reader for BytesReader
of core::cmp::Eq for WriterType
of Writer for {base: T, cleanup: C,}
of Writer for *libc::FILE
of Writer for fd_t
of WriterUtil for T
of Writer for BytesWriter
of Writer for @BytesWriter
BytesWriter
FILERes
FILE_reader
FILE_writer
FdRes
buffered_file_writer
convert_whence
extend_sign
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 {
bytes: &[u8],
mut pos: uint,
}
BytesWriter
pub struct BytesWriter {
bytes: DVec<u8>,
mut pos: uint,
}
FILERes
struct FILERes {
f: *libc::FILE,
}
FdRes
struct FdRes {
fd: fd_t,
}
Reader
The raw underlying reader trait. All readers must implement this.
read
fn read(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() -> int
Read a single byte, returning a negative value for EOF or read error.
eof
fn eof() -> bool
Return whether the stream is currently at EOF position.
seek
fn seek(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() -> uint
Return the current position within the stream.
ReaderUtil
Generic utility functions defined on readers.
read_bytes
fn read_bytes(len: uint) -> ~[u8]
Read len bytes into a new vec.
read_line
fn read_line() -> ~str
Read up until the first '\n' char (which is not returned), or EOF.
read_chars
fn read_chars(n: uint) -> ~[char]
Read n utf-8 encoded chars.
read_char
fn read_char() -> char
Read a single utf-8 encoded char.
read_c_str
fn read_c_str() -> ~str
Read up until the first null byte (which is not returned), or EOF.
read_whole_stream
fn read_whole_stream() -> ~[u8]
Read all the data remaining in the stream in one go.
each_byte
fn each_byte(it: &fn(int) -> bool)
Iterate over every byte until the iterator breaks or EOF.
each_char
fn each_char(it: &fn(char) -> bool)
Iterate over every char until the iterator breaks or EOF.
each_line
fn each_line(it: &fn(&str) -> bool)
Iterate over every line until the iterator breaks or EOF.
read_le_uint_n
fn read_le_uint_n(nbytes: uint) -> u64
Read n (between 1 and 8) little-endian unsigned integer bytes.
read_le_int_n
fn read_le_int_n(nbytes: uint) -> i64
Read n (between 1 and 8) little-endian signed integer bytes.
read_be_uint_n
fn read_be_uint_n(nbytes: uint) -> u64
Read n (between 1 and 8) big-endian unsigned integer bytes.
read_be_int_n
fn read_be_int_n(nbytes: uint) -> i64
Read n (between 1 and 8) big-endian signed integer bytes.
read_le_uint
fn read_le_uint() -> uint
Read a little-endian uint (number of bytes depends on system).
read_le_int
fn read_le_int() -> int
Read a little-endian int (number of bytes depends on system).
read_be_uint
fn read_be_uint() -> uint
Read a big-endian uint (number of bytes depends on system).
read_be_int
fn read_be_int() -> int
Read a big-endian int (number of bytes depends on system).
read_be_u64
fn read_be_u64() -> u64
Read a big-endian u64 (8 bytes).
read_be_u32
fn read_be_u32() -> u32
Read a big-endian u32 (4 bytes).
read_be_u16
fn read_be_u16() -> u16
Read a big-endian u16 (2 bytes).
read_be_i64
fn read_be_i64() -> i64
Read a big-endian i64 (8 bytes).
read_be_i32
fn read_be_i32() -> i32
Read a big-endian i32 (4 bytes).
read_be_i16
fn read_be_i16() -> i16
Read a big-endian i16 (2 bytes).
read_le_u64
fn read_le_u64() -> u64
Read a little-endian u64 (8 bytes).
read_le_u32
fn read_le_u32() -> u32
Read a little-endian u32 (4 bytes).
read_le_u16
fn read_le_u16() -> u16
Read a little-endian u16 (2 bytes).
read_le_i64
fn read_le_i64() -> i64
Read a litle-endian i64 (8 bytes).
read_le_i32
fn read_le_i32() -> i32
Read a litle-endian i32 (4 bytes).
read_le_i16
fn read_le_i16() -> i16
Read a litle-endian i16 (2 bytes).
read_u8
fn read_u8() -> u8
Read a u8 (1 byte).
read_i8
fn read_i8() -> i8
Read a i8 (1 byte).
Writer
The raw underlying writer trait. All writers must implement this.
write
fn write(v: &[const u8])
Write all of the given bytes.
seek
fn seek(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() -> uint
Return the current position within the stream.
flush
fn flush() -> int
Flush the output buffer for this stream (if there is one).
get_type
fn get_type() -> WriterType
Determine if this Writer is writing to a file or not.
WriterUtil
Generic utility functions defined on writers.
write_char
fn write_char(ch: char)
Write a single utf-8 encoded char.
write_str
fn write_str(s: &str)
Write every char in the given str, encoded as utf-8.
write_line
fn write_line(s: &str)
Write the given str, as utf-8, followed by '\n'.
write_int
fn write_int(n: int)
Write the result of passing n through int::to_str_bytes
.
write_uint
fn write_uint(n: uint)
Write the result of passing n through uint::to_str_bytes
.
write_le_uint
fn write_le_uint(n: uint)
Write a little-endian uint (number of bytes depends on system).
write_le_int
fn write_le_int(n: int)
Write a little-endian int (number of bytes depends on system).
write_be_uint
fn write_be_uint(n: uint)
Write a big-endian uint (number of bytes depends on system).
write_be_int
fn write_be_int(n: int)
Write a big-endian int (number of bytes depends on system).
write_be_u64
fn write_be_u64(n: u64)
Write a big-endian u64 (8 bytes).
write_be_u32
fn write_be_u32(n: u32)
Write a big-endian u32 (4 bytes).
write_be_u16
fn write_be_u16(n: u16)
Write a big-endian u16 (2 bytes).
write_be_i64
fn write_be_i64(n: i64)
Write a big-endian i64 (8 bytes).
write_be_i32
fn write_be_i32(n: i32)
Write a big-endian i32 (4 bytes).
write_be_i16
fn write_be_i16(n: i16)
Write a big-endian i16 (2 bytes).
write_le_u64
fn write_le_u64(n: u64)
Write a little-endian u64 (8 bytes).
write_le_u32
fn write_le_u32(n: u32)
Write a little-endian u32 (4 bytes).
write_le_u16
fn write_le_u16(n: u16)
Write a little-endian u16 (2 bytes).
write_le_i64
fn write_le_i64(n: i64)
Write a little-endian i64 (8 bytes).
write_le_i32
fn write_le_i32(n: i32)
Write a little-endian i32 (4 bytes).
write_le_i16
fn write_le_i16(n: i16)
Write a little-endian i16 (2 bytes).
write_u8
fn write_u8(n: u8)
Write a u8 (1 byte).
write_i8
fn write_i8(n: i8)
Write a i8 (1 byte).
ReaderUtil
for T
read_bytes
fn read_bytes(len: uint) -> ~[u8]
read_line
fn read_line() -> ~str
read_chars
fn read_chars(n: uint) -> ~[char]
read_char
fn read_char() -> char
read_c_str
fn read_c_str() -> ~str
read_whole_stream
fn read_whole_stream() -> ~[u8]
each_byte
fn each_byte(it: &fn(int) -> bool)
each_char
fn each_char(it: &fn(char) -> bool)
each_line
fn each_line(it: &fn(s: &str) -> bool)
read_le_uint_n
fn read_le_uint_n(nbytes: uint) -> u64
read_le_int_n
fn read_le_int_n(nbytes: uint) -> i64
read_be_uint_n
fn read_be_uint_n(nbytes: uint) -> u64
read_be_int_n
fn read_be_int_n(nbytes: uint) -> i64
read_le_uint
fn read_le_uint() -> uint
read_le_int
fn read_le_int() -> int
read_be_uint
fn read_be_uint() -> uint
read_be_int
fn read_be_int() -> int
read_be_u64
fn read_be_u64() -> u64
read_be_u32
fn read_be_u32() -> u32
read_be_u16
fn read_be_u16() -> u16
read_be_i64
fn read_be_i64() -> i64
read_be_i32
fn read_be_i32() -> i32
read_be_i16
fn read_be_i16() -> i16
read_le_u64
fn read_le_u64() -> u64
read_le_u32
fn read_le_u32() -> u32
read_le_u16
fn read_le_u16() -> u16
read_le_i64
fn read_le_i64() -> i64
read_le_i32
fn read_le_i32() -> i32
read_le_i16
fn read_le_i16() -> i16
read_u8
fn read_u8() -> u8
read_i8
fn read_i8() -> i8
Reader
for *libc::FILE
read
fn read(bytes: &[mut u8], len: uint) -> uint
read_byte
fn read_byte() -> int
eof
fn eof() -> bool
seek
fn seek(offset: int, whence: SeekStyle)
tell
fn tell() -> uint
Reader
for {base: T, cleanup: C,}
read
fn read(bytes: &[mut u8], len: uint) -> uint
read_byte
fn read_byte() -> int
eof
fn eof() -> bool
seek
fn seek(off: int, whence: SeekStyle)
tell
fn tell() -> uint
Reader
for BytesReader
read
fn read(bytes: &[mut u8], len: uint) -> uint
read_byte
fn read_byte() -> int
eof
fn eof() -> bool
seek
fn seek(offset: int, whence: SeekStyle)
tell
fn tell() -> uint
core::cmp::Eq
for WriterType
eq
fn eq(__other: &WriterType) -> bool
ne
fn ne(__other: &WriterType) -> bool
Writer
for {base: T, cleanup: C,}
write
fn write(bs: &[const u8])
seek
fn seek(off: int, style: SeekStyle)
tell
fn tell() -> uint
flush
fn flush() -> int
get_type
fn get_type() -> WriterType
Writer
for *libc::FILE
write
fn write(v: &[const u8])
seek
fn seek(offset: int, whence: SeekStyle)
tell
fn tell() -> uint
flush
fn flush() -> int
get_type
fn get_type() -> WriterType
Writer
for fd_t
write
fn write(v: &[const u8])
seek
fn seek(_offset: int, _whence: SeekStyle)
tell
fn tell() -> uint
flush
fn flush() -> int
get_type
fn get_type() -> WriterType
WriterUtil
for T
write_char
fn write_char(ch: char)
write_str
fn write_str(s: &str)
write_line
fn write_line(s: &str)
write_int
fn write_int(n: int)
write_uint
fn write_uint(n: uint)
write_le_uint
fn write_le_uint(n: uint)
write_le_int
fn write_le_int(n: int)
write_be_uint
fn write_be_uint(n: uint)
write_be_int
fn write_be_int(n: int)
write_be_u64
fn write_be_u64(n: u64)
write_be_u32
fn write_be_u32(n: u32)
write_be_u16
fn write_be_u16(n: u16)
write_be_i64
fn write_be_i64(n: i64)
write_be_i32
fn write_be_i32(n: i32)
write_be_i16
fn write_be_i16(n: i16)
write_le_u64
fn write_le_u64(n: u64)
write_le_u32
fn write_le_u32(n: u32)
write_le_u16
fn write_le_u16(n: u16)
write_le_i64
fn write_le_i64(n: i64)
write_le_i32
fn write_le_i32(n: i32)
write_le_i16
fn write_le_i16(n: i16)
write_u8
fn write_u8(n: u8)
write_i8
fn write_i8(n: i8)
Writer
for BytesWriter
write
fn write(v: &[const u8])
seek
fn seek(offset: int, whence: SeekStyle)
tell
fn tell() -> uint
flush
fn flush() -> int
get_type
fn get_type() -> WriterType
Writer
for @BytesWriter
write
fn write(v: &[const u8])
seek
fn seek(offset: int, whence: SeekStyle)
tell
fn tell() -> uint
flush
fn flush() -> int
get_type
fn get_type() -> 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>
convert_whence
fn convert_whence(whence: SeekStyle) -> i32
extend_sign
fn extend_sign(val: u64, nbytes: uint) -> i64
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