Function in io::sync coil-stdlib

write_all

fn write_all(Stream s, Vec<byte> buf) -> Result<int, IoError>
Import
use io::sync::{write_all};
Source: 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#

NameType
sStream
bufVec<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::write
  • read_exact: Fills all of buf from s, waiting whenever no data is ready.
  • read_to_end: Reads from s until it ends and returns everything read.
  • accept_wait: Waits for the next connection on a TCP listener and returns its stream.
  • recv_from_wait: Waits for a UDP datagram, reads it into buf, and returns (bytes, sender host, sender port).
  • send_to_wait: Sends buf as one UDP datagram to host:port, waiting while the socket is not ready.
  • copy: Copies the file src to dst.
  • print: Writes s to standard output, without a newline.
↑ ↓ navigate ↵ open