std.io
struct BufReader
struct BufWriter
struct Bytes
struct Chunks
interface Close
struct Cursor
struct Empty
struct IoError
struct MultiRead
struct Pipe
interface Read
interface ReadClose
interface ReadSeek
interface ReadWrite
interface ReadWriteClose
interface Seek
enum SeekFrom
type Stderr = Stderr
struct Stdin
type Stdout = Stdout
interface Write
interface WriteClose
interface WriteSeek
_create_native_read
pub fn _create_native_read(read: Read): NativeRead
[src]
pub fn _create_native_read(read: Read): NativeRead {
return NativeRead.new(|buf| try read.read(buf));
}
_create_native_read
pub fn _create_native_read(read: Read): NativeRead
[src]
pub fn _create_native_read(read: Read): NativeRead {
return NativeRead.new(|buf| try read.read(buf));
}
_create_native_read_seek
pub fn _create_native_read_seek(readseek: ReadSeek): NativeReadSeek
[src]
pub fn _create_native_read_seek(readseek: ReadSeek): NativeReadSeek {
return NativeReadSeek
.new(
|buf| try readseek.read(buf),
|offset, pos| try readseek.seek(offset, (pos as SeekFrom)!)
);
}
_create_native_read_seek
pub fn _create_native_read_seek(readseek: ReadSeek): NativeReadSeek
[src]
pub fn _create_native_read_seek(readseek: ReadSeek): NativeReadSeek {
return NativeReadSeek
.new(
|buf| try readseek.read(buf),
|offset, pos| try readseek.seek(offset, (pos as SeekFrom)!)
);
}
_create_native_readclose
pub fn _create_native_readclose(read: ReadClose): NativeReadClose
[src]
pub fn _create_native_readclose(read: ReadClose): NativeReadClose {
return NativeReadClose.new(|buf| try read.read(buf), || try read.close());
}
_create_native_readclose
pub fn _create_native_readclose(read: ReadClose): NativeReadClose
[src]
pub fn _create_native_readclose(read: ReadClose): NativeReadClose {
return NativeReadClose.new(|buf| try read.read(buf), || try read.close());
}
_create_native_readwrite
pub fn _create_native_readwrite(readwrite: ReadWrite): NativeReadWrite
[src]
pub fn _create_native_readwrite(readwrite: ReadWrite): NativeReadWrite {
return NativeReadWrite
.new(
|buf| try readwrite.read(buf),
|buf| try readwrite.write(buf),
|| try readwrite.flush()
);
}
_create_native_readwrite
pub fn _create_native_readwrite(readwrite: ReadWrite): NativeReadWrite
[src]
pub fn _create_native_readwrite(readwrite: ReadWrite): NativeReadWrite {
return NativeReadWrite
.new(
|buf| try readwrite.read(buf),
|buf| try readwrite.write(buf),
|| try readwrite.flush()
);
}
_create_native_readwriteclose
pub fn _create_native_readwriteclose(readwrite: ReadWriteClose): NativeReadWriteClose
[src]
pub fn _create_native_readwriteclose(readwrite: ReadWriteClose): NativeReadWriteClose {
return NativeReadWriteClose
.new(
|buf| try readwrite.read(buf),
|buf| try readwrite.write(buf),
|| try readwrite.flush(),
|| try readwrite.close()
);
}
_create_native_readwriteclose
pub fn _create_native_readwriteclose(readwrite: ReadWriteClose): NativeReadWriteClose
[src]
pub fn _create_native_readwriteclose(readwrite: ReadWriteClose): NativeReadWriteClose {
return NativeReadWriteClose
.new(
|buf| try readwrite.read(buf),
|buf| try readwrite.write(buf),
|| try readwrite.flush(),
|| try readwrite.close()
);
}
_create_native_write
pub fn _create_native_write(write: Write): NativeWrite
[src]
pub fn _create_native_write(write: Write): NativeWrite {
return NativeWrite.new(|buf| try write.write(buf), || try write.flush());
}
_create_native_write
pub fn _create_native_write(write: Write): NativeWrite
[src]
pub fn _create_native_write(write: Write): NativeWrite {
return NativeWrite.new(|buf| try write.write(buf), || try write.flush());
}
_create_native_write_seek
pub fn _create_native_write_seek(writeseek: WriteSeek): NativeWriteSeek
[src]
pub fn _create_native_write_seek(writeseek: WriteSeek): NativeWriteSeek {
return NativeWriteSeek
.new(
|buf| try writeseek.write(buf),
|| try writeseek.flush(),
|offset, pos| try writeseek.seek(offset, (pos as SeekFrom)!)
);
}
_create_native_write_seek
pub fn _create_native_write_seek(writeseek: WriteSeek): NativeWriteSeek
[src]
pub fn _create_native_write_seek(writeseek: WriteSeek): NativeWriteSeek {
return NativeWriteSeek
.new(
|buf| try writeseek.write(buf),
|| try writeseek.flush(),
|offset, pos| try writeseek.seek(offset, (pos as SeekFrom)!)
);
}
_create_native_writeclose
pub fn _create_native_writeclose(write: WriteClose): NativeWriteClose
[src]
pub fn _create_native_writeclose(write: WriteClose): NativeWriteClose {
return NativeWriteClose
.new(|buf| try write.write(buf), || try write.flush(), || try write.close());
}
_create_native_writeclose
pub fn _create_native_writeclose(write: WriteClose): NativeWriteClose
[src]
pub fn _create_native_writeclose(write: WriteClose): NativeWriteClose {
return NativeWriteClose
.new(|buf| try write.write(buf), || try write.flush(), || try write.close());
}
[src]
pub fn copy(reader: Read, writer: Write): int throws IoError {
let buf = Bytes.new(len: 8192);
let total = 0;
loop {
let n = try reader.read(buf);
if (n == 0) {
break;
}
total += n;
try! writer.write(buf.slice(0, n));
}
return total;
}
Copies the entire contents of a reader into a writer.
[src]
pub fn copy(reader: Read, writer: Write): int throws IoError {
let buf = Bytes.new(len: 8192);
let total = 0;
loop {
let n = try reader.read(buf);
if (n == 0) {
break;
}
total += n;
try! writer.write(buf.slice(0, n));
}
return total;
}
Copies the entire contents of a reader into a writer.
Copies the entire contents of a reader into a writer.
This function will continuously read data from reader
and then write it
into writer
in a streaming fashion until reader
returns EOF.
On success, the total number of bytes that were copied from reader
to writer
is returned.
If you want to copy the contents of one file to another and you’re working with filesystem paths,
see the std.fs.copy
function.
Errors
if any call to read or write returns an error.
Examples
use std.io.{self, Cursor, Bytes};
let reader = Cursor.new("Hello world");
let writer = Bytes.new();
try! io.copy(reader, writer);
assert_eq writer.to_string(), "Hello world";
[src]
pub fn pipe(buffer_size: int = 4096): Pipe {
return Pipe {
wch: channel(),
rch: channel(),
buffers: [],
buffer_size: 0,
max_buffer_size: buffer_size,
};
}
Creates a synchronous in-memory pipe.
[src]
pub fn pipe(buffer_size: int = 4096): Pipe {
return Pipe {
wch: channel(),
rch: channel(),
buffers: [],
buffer_size: 0,
max_buffer_size: buffer_size,
};
}
Creates a synchronous in-memory pipe.
Creates a synchronous in-memory pipe.
It can be used to connect code expecting an io.Reader`` with code expecting an
io.Writer`.
[src]
pub fn print(values: ..ToString?) {
let first = true;
for (let value in values) {
if (!first) {
_print(" ");
} else {
first = false;
}
if (let value = value) {
_print(value.to_string());
} else {
_print("nil");
}
}
}
Print value to stdout.
[src]
pub fn print(values: ..ToString?) {
let first = true;
for (let value in values) {
if (!first) {
_print(" ");
} else {
first = false;
}
if (let value = value) {
_print(value.to_string());
} else {
_print("nil");
}
}
}
Print value to stdout.
Print value to stdout.
print("Hello, world!");
[src]
pub fn println(values: ..ToString?) {
print(..values, "\n");
}
Print value to stdout and append a newline.
[src]
pub fn println(values: ..ToString?) {
print(..values, "\n");
}
Print value to stdout and append a newline.
Print value to stdout and append a newline.
println("Hello, world!");
// If you want to use string interpolation, use backticks.
let name = "Jason";
println(`Hello, ${name}!`);
// => Hello, Jason!
println(`Hello,`, name);
// => Hello, Jason
println(`Hello,`, 1000, 3.14, true, false);
// => Hello, 1000 3.14 true false
[src]
pub fn stderr(): Stderr {
return STDERR as Stderr;
}
Get STDERR.
[src]
pub fn stderr(): Stderr {
return STDERR as Stderr;
}
Get STDERR.
Get STDERR.
use std.io;
fn main() throws {
try io.stderr().write("Hello, world!".bytes());
/// eprint "Hello, world!"
}
[src]
pub fn stdin(): Stdin {
return Stdin { inner: BufReader.new(STDIN as InnerStdin) };
}
Get STDIN.
[src]
pub fn stdin(): Stdin {
return Stdin { inner: BufReader.new(STDIN as InnerStdin) };
}
Get STDIN.
Get STDIN.
use std.io;
fn main() throws {
let s = try io.stdin().read_line();
println(`${s}`);
}