std.sys.Stdout
class pub Stdout
The standard output stream.
Static methods
new
Show source codeHide source code
fn pub static new(process: ref ChildProcess) -> Stdout {
Stdout(process)
}
fn pub static new(process: ref ChildProcess) -> Stdout
Instance methods
read
Show source codeHide source code
fn pub mut read(into: mut ByteArray, size: Int) -> Result[Int, Error] {
match
inko_child_process_stdout_read(_INKO.process, @process.raw, into, size)
{
case { @tag = 0, @value = v } -> Result.Ok(v)
case { @tag = _, @value = e } -> Result.Error(Error.from_os_error(e))
}
}
fn pub mut read(into: mut ByteArray, size: Int) -> Result[Int, Error]
Reads bytes from a stream into a ByteArray
.
The return value is the number of bytes read.
The size
argument specifies how many bytes are to be read. The actual
number of bytes read may be less than this value.
read_all
Show source codeHide source code
fn pub mut read_all(bytes: mut ByteArray) -> Result[Int, Error] {
let mut total = 0
let mut read_size = INITIAL_READ_ALL_SIZE
loop {
let bytes_read = try read(into: bytes, size: read_size)
if bytes_read == 0 { return Result.Ok(total) }
total += bytes_read
# To reduce the overhead of large buffer reads, we increase the buffer
# size as more data is read.
if read_size < MAX_READ_ALL_SIZE { read_size *= 2 }
}
}
fn pub mut read_all(bytes: mut ByteArray) -> Result[Int, Error]
Reads all bytes from the stream into the ByteArray
.
If an error is encountered while reading, this method stops reading any more bytes and re-throws the error.
The return value is the number of bytes read.
Implemented traits
Drop
impl Drop for Stdout
Read
impl Read for Stdout