write_all
fn write_all(Stream s, Vec<byte> buf) -> Result<int, IoError> Import
Source: use io::sync::{write_all}; src/io/sync.hy Writes all of buf to s, waiting whenever the stream is not ready.
io::write may write only part of a buffer; this keeps going until every
byte is out, then returns Ok(0). Inside a task, the waits let other
tasks run.
Parameters#
| Name | Type |
|---|---|
s | Stream |
buf | Vec<byte> |
Returns#
Result<int, IoError>
Examples#
use io::sync::{write_all};
use tests::assert;
use io::{stdout};
use string::{to_bytes};
let written = write_all(stdout(), to_bytes("hi\n"));
assert!(written.is_ok());
See also#
io::writeread_exact: Fills all ofbuffroms, waiting whenever no data is ready.read_to_end: Reads fromsuntil it ends and returns everything read.accept_wait: Waits for the next connection on a TCPlistenerand returns its stream.recv_from_wait: Waits for a UDP datagram, reads it intobuf, and returns(bytes, sender host, sender port).send_to_wait: Sendsbufas one UDP datagram tohost:port, waiting while the socket is not ready.copy: Copies the filesrctodst.print: Writessto standard output, without a newline.