Io module

write

procedure · 8 overloadsSource

Sends all of data, waiting as often as it takes. On an error it returns how many bytes went out.

write :: (stream: Tcp_Stream, data: [] u8) -> (s64, Io_Error)

Sends all of data, waiting as often as it takes. On an error it returns how many bytes went out.

Parameters

stream: Tcp_Stream
data: [] u8

Returns

s64
write :: (stream: Tcp_Stream, text: string) -> (s64, Io_Error)

The write for a string: sends all of text.

Parameters

stream: Tcp_Stream
text: string

Returns

s64
write :: (stream: *Pipe_Stream, data: [] u8) -> (s64, Io_Error)

Hands data to the other end. Never waits. .BROKEN_PIPE if the other end is closed.

Parameters

stream: *Pipe_Stream
data: [] u8

Returns

s64
write :: (stream: *Pipe_Stream, text: string) -> (s64, Io_Error)

The write for a string: sends all of text into the pipe, to be read at the other end.

Parameters

stream: *Pipe_Stream
text: string

Returns

s64
Example
Io :: #import "Extensions/Io";

main :: () {
    Io.io_run(() {
        near, far := Io.make_pipe();

        Io.write(near, "hello");
        Io.shutdown_write(near);

        text, error := Io.read_all(Io.reader_of(far));
        assert(error == .NONE && string.{ text.count, text.data } == "hello");
        free(text.data);

        Io.close(near);
        Io.close(far);
    });
}

Doesn't run in the browser (skipped on wasm).

write :: (file: *Io_File, data: [] u8) -> (s64, Io_Error)

Writes all of data at the file's position (at the end, for .APPEND).

Parameters

file: *Io_File
data: [] u8

Returns

s64
write :: (file: *Io_File, text: string) -> (s64, Io_Error)

Parameters

file: *Io_File
text: string

Returns

s64
write :: (writer: Writer, data: [] u8) -> (s64, Io_Error)

Sends all of data, waiting as often as it takes. On an error it returns how many bytes went out.

Parameters

writer: Writer
data: [] u8

Returns

s64
write :: (writer: Writer, text: string) -> (s64, Io_Error)

The write for a string: sends all of text and returns how many bytes went out.

Parameters

writer: Writer
text: string

Returns

s64

See also