[]Struct gio::IOStream

pub struct IOStream(_, _);

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

Examples of IOStream objects are SocketConnection, which represents a two-way network connection; and FileIOStream, which represents a file handle opened in read-write mode.

To do the actual reading and writing you need to get the substreams with IOStreamExt::get_input_stream and IOStreamExt::get_output_stream.

The IOStream object owns the input and the output streams, not the other way around, so keeping the substreams alive will not keep the IOStream object alive. If the IOStream object is freed it will be closed, thus closing the substreams, so even if the substreams stay alive they will always return IOErrorEnum::Closed for all operations.

To close a stream use IOStreamExt::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 but common state in the IOStream may still be open. However, some streams may support "half-closed" states where one direction of the stream is actually shut down.

Operations on GIOStreams cannot be started while another operation on the IOStream or its substreams is in progress. Specifically, an application can read from the InputStream and write to the OutputStream simultaneously (either in separate threads, or as asynchronous operations in the same thread), but an application cannot start any IOStream operation while there is a IOStream, InputStream or OutputStream operation in progress, and an application can’t start any InputStream or OutputStream operation while there is a IOStream operation in progress.

This is a product of individual stream operations being associated with a given glib::MainContext (the thread-default context at the time the operation was started), rather than entire streams being associated with a single glib::MainContext.

GIO may run operations on GIOStreams from other (worker) threads, and this may be exposed to application code in the behaviour of wrapper streams, such as BufferedInputStream or TlsConnection. With such wrapper APIs, application code may only run operations on the base (wrapped) stream when the wrapper stream is idle. Note that the semantics of such operations may not be well-defined due to the state the wrapper stream leaves the base stream in (though they are guaranteed not to crash).

Implements

IOStreamExt, glib::object::ObjectExt, IOStreamExtManual

Trait Implementations

impl Clone for IOStream

impl Debug for IOStream

impl Display for IOStream[src]

impl Eq for IOStream

impl Hash for IOStream

impl IsA<IOStream> for FileIOStream

impl IsA<IOStream> for SimpleIOStream

impl IsA<IOStream> for SocketConnection

impl IsA<IOStream> for TcpConnection

impl IsA<IOStream> for TlsClientConnection

impl IsA<IOStream> for TlsConnection

impl IsA<IOStream> for TlsServerConnection

impl Ord for IOStream

impl<T: ObjectType> PartialEq<T> for IOStream

impl<T: ObjectType> PartialOrd<T> for IOStream

impl StaticType for IOStream

Auto Trait Implementations

impl RefUnwindSafe for IOStream

impl !Send for IOStream

impl !Sync for IOStream

impl Unpin for IOStream

impl UnwindSafe for IOStream

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.