Gio.OutputStream.prototype.write_bytes_async
function write_bytes_async(bytes: ByteArray, io_priority: Number(gint), cancellable: Gio.Cancellable, callback: Gio.AsyncReadyCallback): void { // Gjs wrapper for g_output_stream_write_bytes_async() }
This function is similar to Gio.OutputStream.prototype.write_async, but takes a GLib.Bytes as input. Due to the refcounted nature of GLib.Bytes, this allows the stream to avoid taking a copy of the data.
However, note that this function may still perform partial writes, just like Gio.OutputStream.prototype.write_async. If that occurs, to continue writing, you will need to create a new GLib.Bytes containing just the remaining bytes, using GLib.Bytes.prototype.new_from_bytes. Passing the same GLib.Bytes instance multiple times potentially can result in duplicated data in the output stream.
For the synchronous, blocking version of this function, see Gio.OutputStream.prototype.write_bytes.
- bytes
The bytes to write
- io_priority
the io priority of the request.
- cancellable
optional Gio.Cancellable object, null to ignore.
- callback
callback to call when the request is satisfied