Gio.PollableOutputStream.prototype.write_nonblocking
function write_nonblocking(buffer: ByteArray, cancellable: Gio.Cancellable): Number(gssize) {
// Gjs wrapper for g_pollable_output_stream_write_nonblocking()
}
Attempts to write up to count bytes from buffer to stream, as with Gio.OutputStream.prototype.write. If stream is not currently writable, this will immediately return Gio.IOErrorEnum.would_block, and you can use Gio.PollableOutputStream.prototype.create_source to create a GLib.Source that will be triggered when stream is writable.
Note that since this method never blocks, you cannot actually use cancellable to cancel it. However, it will return an error if cancellable has already been cancelled when you call, which may happen if you call this method after a source triggers due to having been cancelled.
- buffer
a buffer to write data from
- cancellable
a Gio.Cancellable, or null
- Returns
the number of bytes written, or -1 on error (including Gio.IOErrorEnum.would_block).