gio::prelude

Trait IOStreamExt

Source
pub trait IOStreamExt: IsA<IOStream> + 'static {
    // Provided methods
    fn clear_pending(&self) { ... }
    fn close(
        &self,
        cancellable: Option<&impl IsA<Cancellable>>,
    ) -> Result<(), Error> { ... }
    fn close_async<P: FnOnce(Result<(), Error>) + 'static>(
        &self,
        io_priority: Priority,
        cancellable: Option<&impl IsA<Cancellable>>,
        callback: P,
    ) { ... }
    fn close_future(
        &self,
        io_priority: Priority,
    ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
    fn input_stream(&self) -> InputStream { ... }
    fn output_stream(&self) -> OutputStream { ... }
    fn has_pending(&self) -> bool { ... }
    fn is_closed(&self) -> bool { ... }
    fn set_pending(&self) -> Result<(), Error> { ... }
    fn connect_closed_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all IOStream methods.

§Implementors

FileIOStream, IOStream, SimpleIOStream, SocketConnection, TlsConnection

Provided Methods§

Source

fn clear_pending(&self)

Clears the pending flag on @self.

Source

fn close( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>

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 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 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 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.

§cancellable

optional #GCancellable object, None to ignore

§Returns

true on success, false on failure

Source

fn close_async<P: FnOnce(Result<(), Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

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 g_io_stream_close_finish() to get the result of the operation.

For behaviour details see g_io_stream_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.

§io_priority

the io priority of the request

§cancellable

optional cancellable object

§callback

a #GAsyncReadyCallback to call when the request is satisfied

Source

fn close_future( &self, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

Source

fn input_stream(&self) -> InputStream

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

§Returns

a #GInputStream, owned by the #GIOStream. Do not free.

Source

fn output_stream(&self) -> OutputStream

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

§Returns

a #GOutputStream, owned by the #GIOStream. Do not free.

Source

fn has_pending(&self) -> bool

Checks if a stream has pending actions.

§Returns

true if @self has pending actions.

Source

fn is_closed(&self) -> bool

Checks if a stream is closed.

§Returns

true if the stream is closed.

Source

fn set_pending(&self) -> Result<(), Error>

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

§Returns

true if pending was previously unset and is now set.

Source

fn connect_closed_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§