W Wrapl, The Programming Language




Inherits from:

GIOStream represents an object that has both read and write streams. Generally the two streams acts as separate input and output streams, but they share some common resources and state. For instance, for seekable streams they may use the same position in both streams.

Examples of T objects are Gtk.Gio.GSocketConnection.T which represents a two-way network connection, and Gtk.Gio.GFileIOStream.T which represent a file handle opened in read-write mode.

To do the actual reading and writing you need to get the substreams with GetInputStream and GetOutputStream.

The T object owns the input and the output streams, not the other way around, so keeping the substreams alive will not keep the T object alive. If the T object is freed it will be closed, thus closing the substream, so even if the substreams stay alive they will always just return a Gtk.Gio.GIOErrorEnum.Closed for all operations.

To close a stream use Close which will close the common stream object and also the individual substreams. You can also close the substreams themselves. In most cases this only marks the substream as closed, so further I/O on it fails. However, some streams may support "half-closed" states where one direction of the stream is actually shut down.


Nil : T


GetType() : Gtk.GObject.Type.T


:ClearPending(self @ T) : Std.Object.T

Clears the pending flag on stream.

stream a T

:Close(self @ T, cancellable @ Gtk.Gio.GCancellable.T, error @ Std.Object.T) : Std.Symbol.T

Closes the stream, releasing resources related to it. This will also closes the individual input and output streams, if they are not already closed.

Once the stream is closed, all other operations will return Gtk.Gio.GIOErrorEnum.Closed. Closing a stream multiple times will not return an error.

Closing a stream will automatically flush any outstanding buffers in the stream.

Streams will be automatically closed when the last reference is dropped, but you might want to call this function to make sure resources are released as early as possible.

Some streams might keep the backing store of the stream (e.g. a file descriptor) open after the stream is closed. See the documentation for the individual stream for details.

On failure the first error that happened will be reported, but the close operation will finish as much as possible. A stream that failed to close will still return Gtk.Gio.GIOErrorEnum.Closed for all operations. Still, it is important to check and report the error to the user, otherwise there might be a loss of data as all data might not be written.

If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gtk.Gio.GIOErrorEnum.Cancelled will be returned. Cancelling a close will still leave the stream closed, but some streams can use a faster close that doesn't block to e.g. check errors.

The default implementation of this method just calls close on the individual input/output streams.

stream a T
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
error location to store the error occurring, or NULL to ignore
Returns TRUE on success, FALSE on failure

:CloseAsync(self @ T, io_priority @ Std.Integer.SmallT, cancellable @ Gtk.Gio.GCancellable.T, callback @ Std.Function.T, user_data) : Std.Object.T

Requests an asynchronous close of the stream, releasing resources related to it. When the operation is finished callback will be called. You can then call CloseFinish to get the result of the operation.

For behaviour details see Close.

The asynchronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.

stream a T
io_priority the io priority of the request
cancellable optional cancellable object. [allow-none]
callback callback to call when the request is satisfied. [scope async]
user_data the data to pass to callback function. [closure]

:CloseFinish(self @ T, result @ Gtk.Gio.GAsyncResult.T, error @ Std.Object.T) : Std.Symbol.T

Closes a stream.

stream a T
result a Gtk.Gio.GAsyncResult.T
error a Gtk.Glib.GError.T location to store the error occurring, or NULL to ignore
Returns TRUE if stream was successfully closed, FALSE otherwise.

:GetInputStream(self @ T) : Gtk.Gio.GInputStream.T

Gets the input stream for this object. This is used for reading.

stream a T
Returns a Gtk.Gio.GInputStream.T, owned by the T. Do not free. [transfer none]

:GetOutputStream(self @ T) : Gtk.Gio.GOutputStream.T

Gets the output stream for this object. This is used for writing.

stream a T
Returns a Gtk.Gio.GOutputStream.T, owned by the T. Do not free. [transfer none]

:HasPending(self @ T) : Std.Symbol.T

Checks if a stream has pending actions.

stream a T
Returns TRUE if stream has pending actions.

:IsClosed(self @ T) : Std.Symbol.T

Checks if a stream is closed.

stream a T
Returns TRUE if the stream is closed.

:Priv(self @ T) : Std.Object.T

:SetPending(self @ T, error @ Std.Object.T) : Std.Symbol.T

Sets stream to have actions pending. If the pending flag is already set or stream is closed, it will return FALSE and set error.

stream a T
error a Gtk.Glib.GError.T location to store the error occurring, or NULL to ignore
Returns TRUE if pending was previously unset and is now set.

:setPriv(self @ T, value @ Std.Object.T) : Std.Object.T