:right-sidebar: True IOStream =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.22 .. class:: IOStream(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gio.FileIOStream`, :class:`~gi.repository.Gio.SimpleIOStream`, :class:`~gi.repository.Gio.SocketConnection`, :class:`~gi.repository.Gio.TlsConnection` :Constructors: :: IOStream(**properties) Methods ------- .. rst-class:: interim-class .. class:: IOStream :no-index: .. method:: clear_pending() -> None Clears the pending flag on ``stream``. .. versionadded:: 2.22 .. method:: close(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Closes the stream, releasing resources related to it. This will also close the individual input and output streams, if they are not already closed. Once the stream is closed, all other operations will return :const:`~gi.repository.Gio.IOErrorEnum.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 :const:`~gi.repository.Gio.IOErrorEnum.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 :const:`~gi.repository.Gio.IOErrorEnum.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. .. versionadded:: 2.22 :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: close_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None 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 :func:`~gi.repository.Gio.IOStream.close_finish` to get the result of the operation. For behaviour details see :func:`~gi.repository.Gio.IOStream.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. .. versionadded:: 2.22 :param io_priority: the io priority of the request :param cancellable: optional cancellable object :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: close_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Closes a stream. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: get_input_stream() -> ~gi.repository.Gio.InputStream Gets the input stream for this object. This is used for reading. .. versionadded:: 2.22 .. method:: get_output_stream() -> ~gi.repository.Gio.OutputStream Gets the output stream for this object. This is used for writing. .. versionadded:: 2.22 .. method:: has_pending() -> bool Checks if a stream has pending actions. .. versionadded:: 2.22 .. method:: is_closed() -> bool Checks if a stream is closed. .. versionadded:: 2.22 .. method:: set_pending() -> bool Sets ``stream`` to have actions pending. If the pending flag is already set or ``stream`` is closed, it will return :const:`False` and set ``error``. .. versionadded:: 2.22 .. method:: splice_async(stream2: ~gi.repository.Gio.IOStream, flags: ~gi.repository.Gio.IOStreamSpliceFlags, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Asynchronously splice the output stream of ``stream1`` to the input stream of ``stream2``, and splice the output stream of ``stream2`` to the input stream of ``stream1``. When the operation is finished ``callback`` will be called. You can then call :func:`~gi.repository.Gio.IOStream.splice_finish` to get the result of the operation. .. versionadded:: 2.28 :param stream2: a :obj:`~gi.repository.Gio.IOStream`. :param flags: a set of :obj:`~gi.repository.Gio.IOStreamSpliceFlags`. :param io_priority: the io priority of the request. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: splice_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous io stream splice operation. .. versionadded:: 2.28 :param result: a :obj:`~gi.repository.Gio.AsyncResult`. Properties ---------- .. rst-class:: interim-class .. class:: IOStream :no-index: .. attribute:: props.closed :type: bool Whether the stream is closed. .. versionadded:: 2.22 .. attribute:: props.input_stream :type: ~gi.repository.Gio.InputStream The :obj:`~gi.repository.Gio.InputStream` to read from. .. versionadded:: 2.22 .. attribute:: props.output_stream :type: ~gi.repository.Gio.OutputStream The :obj:`~gi.repository.Gio.OutputStream` to write to. .. versionadded:: 2.22 Virtual Methods --------------- .. rst-class:: interim-class .. class:: IOStream :no-index: .. method:: do_close_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None 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 :func:`~gi.repository.Gio.IOStream.close_finish` to get the result of the operation. For behaviour details see :func:`~gi.repository.Gio.IOStream.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. .. versionadded:: 2.22 :param io_priority: the io priority of the request :param cancellable: optional cancellable object :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_close_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Closes a stream. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: do_close_fn(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool :param cancellable: .. method:: do_get_input_stream() -> ~gi.repository.Gio.InputStream Gets the input stream for this object. This is used for reading. .. versionadded:: 2.22 .. method:: do_get_output_stream() -> ~gi.repository.Gio.OutputStream Gets the output stream for this object. This is used for writing. .. versionadded:: 2.22 Fields ------ .. rst-class:: interim-class .. class:: IOStream :no-index: .. attribute:: parent_instance .. attribute:: priv