Gio.PollableInputStream.prototype.read_nonblocking
function read_nonblocking(buffer: void, count: Number(gsize), cancellable: Gio.Cancellable): Number(gssize) {
// Gjs wrapper for g_pollable_input_stream_read_nonblocking()
}
Attempts to read up to count bytes from stream into buffer, as with Gio.InputStream.prototype.read. If stream is not currently readable, this will immediately return Gio.IOErrorEnum.would_block, and you can use Gio.PollableInputStream.prototype.create_source to create a GLib.Source that will be triggered when stream is readable.
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 read data into (which should be at least count bytes long).
- count
the number of bytes you want to read
- cancellable
a Gio.Cancellable, or null
- Returns
the number of bytes read, or -1 on error (including Gio.IOErrorEnum.would_block).