gi-gio
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Interfaces.PollableOutputStream

Description

GPollableOutputStream is implemented by OutputStreams that can be polled for readiness to write. This can be used when interfacing with a non-GIO API that expects UNIX-file-descriptor-style asynchronous I/O rather than GIO-style.

Some classes may implement GPollableOutputStream but have only certain instances of that class be pollable. If pollableOutputStreamCanPoll returns false, then the behavior of other GPollableOutputStream methods is undefined.

Since: 2.28

Synopsis

Exported types

newtype PollableOutputStream Source #

Memory-managed wrapper type.

Instances

Instances details
Eq PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

GObject PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

ManagedPtrNewtype PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

TypedObject PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

Methods

glibType :: IO GType #

HasParentTypes PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

HasAttributeList PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

(info ~ ResolvePollableOutputStreamMethod t PollableOutputStream, OverloadedMethod info PollableOutputStream p, HasField t PollableOutputStream p) => HasField (t :: Symbol) PollableOutputStream (p :: Type) Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

(info ~ ResolvePollableOutputStreamMethod t PollableOutputStream, OverloadedMethodInfo info PollableOutputStream) => IsLabel t (MethodProxy info PollableOutputStream) Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

(info ~ ResolvePollableOutputStreamMethod t PollableOutputStream, OverloadedMethod info PollableOutputStream p) => IsLabel t (PollableOutputStream -> p) Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

IsGValue (Maybe PollableOutputStream) Source #

Convert PollableOutputStream to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

type AttributeList PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

type ParentTypes PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

type SignalList PollableOutputStream Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

class (GObject o, IsDescendantOf PollableOutputStream o) => IsPollableOutputStream o Source #

Type class for types which can be safely cast to PollableOutputStream, for instance with toPollableOutputStream.

Instances

Instances details
(GObject o, IsDescendantOf PollableOutputStream o) => IsPollableOutputStream o Source # 
Instance details

Defined in GI.Gio.Interfaces.PollableOutputStream

toPollableOutputStream :: (MonadIO m, IsPollableOutputStream o) => o -> m PollableOutputStream Source #

Cast to PollableOutputStream, for types for which this is known to be safe. For general casts, use castTo.

Methods

type family ResolvePollableOutputStreamMethod (t :: Symbol) o where ... Source #

Equations

ResolvePollableOutputStreamMethod "bindProperty" o = ObjectBindPropertyMethodInfo 
ResolvePollableOutputStreamMethod "bindPropertyFull" o = ObjectBindPropertyFullMethodInfo 
ResolvePollableOutputStreamMethod "canPoll" o = PollableOutputStreamCanPollMethodInfo 
ResolvePollableOutputStreamMethod "clearPending" o = OutputStreamClearPendingMethodInfo 
ResolvePollableOutputStreamMethod "close" o = OutputStreamCloseMethodInfo 
ResolvePollableOutputStreamMethod "closeAsync" o = OutputStreamCloseAsyncMethodInfo 
ResolvePollableOutputStreamMethod "closeFinish" o = OutputStreamCloseFinishMethodInfo 
ResolvePollableOutputStreamMethod "createSource" o = PollableOutputStreamCreateSourceMethodInfo 
ResolvePollableOutputStreamMethod "flush" o = OutputStreamFlushMethodInfo 
ResolvePollableOutputStreamMethod "flushAsync" o = OutputStreamFlushAsyncMethodInfo 
ResolvePollableOutputStreamMethod "flushFinish" o = OutputStreamFlushFinishMethodInfo 
ResolvePollableOutputStreamMethod "forceFloating" o = ObjectForceFloatingMethodInfo 
ResolvePollableOutputStreamMethod "freezeNotify" o = ObjectFreezeNotifyMethodInfo 
ResolvePollableOutputStreamMethod "getv" o = ObjectGetvMethodInfo 
ResolvePollableOutputStreamMethod "hasPending" o = OutputStreamHasPendingMethodInfo 
ResolvePollableOutputStreamMethod "isClosed" o = OutputStreamIsClosedMethodInfo 
ResolvePollableOutputStreamMethod "isClosing" o = OutputStreamIsClosingMethodInfo 
ResolvePollableOutputStreamMethod "isFloating" o = ObjectIsFloatingMethodInfo 
ResolvePollableOutputStreamMethod "isWritable" o = PollableOutputStreamIsWritableMethodInfo 
ResolvePollableOutputStreamMethod "notify" o = ObjectNotifyMethodInfo 
ResolvePollableOutputStreamMethod "notifyByPspec" o = ObjectNotifyByPspecMethodInfo 
ResolvePollableOutputStreamMethod "ref" o = ObjectRefMethodInfo 
ResolvePollableOutputStreamMethod "refSink" o = ObjectRefSinkMethodInfo 
ResolvePollableOutputStreamMethod "runDispose" o = ObjectRunDisposeMethodInfo 
ResolvePollableOutputStreamMethod "splice" o = OutputStreamSpliceMethodInfo 
ResolvePollableOutputStreamMethod "spliceAsync" o = OutputStreamSpliceAsyncMethodInfo 
ResolvePollableOutputStreamMethod "spliceFinish" o = OutputStreamSpliceFinishMethodInfo 
ResolvePollableOutputStreamMethod "stealData" o = ObjectStealDataMethodInfo 
ResolvePollableOutputStreamMethod "stealQdata" o = ObjectStealQdataMethodInfo 
ResolvePollableOutputStreamMethod "thawNotify" o = ObjectThawNotifyMethodInfo 
ResolvePollableOutputStreamMethod "unref" o = ObjectUnrefMethodInfo 
ResolvePollableOutputStreamMethod "watchClosure" o = ObjectWatchClosureMethodInfo 
ResolvePollableOutputStreamMethod "write" o = OutputStreamWriteMethodInfo 
ResolvePollableOutputStreamMethod "writeAll" o = OutputStreamWriteAllMethodInfo 
ResolvePollableOutputStreamMethod "writeAllAsync" o = OutputStreamWriteAllAsyncMethodInfo 
ResolvePollableOutputStreamMethod "writeAllFinish" o = OutputStreamWriteAllFinishMethodInfo 
ResolvePollableOutputStreamMethod "writeAsync" o = OutputStreamWriteAsyncMethodInfo 
ResolvePollableOutputStreamMethod "writeBytes" o = OutputStreamWriteBytesMethodInfo 
ResolvePollableOutputStreamMethod "writeBytesAsync" o = OutputStreamWriteBytesAsyncMethodInfo 
ResolvePollableOutputStreamMethod "writeBytesFinish" o = OutputStreamWriteBytesFinishMethodInfo 
ResolvePollableOutputStreamMethod "writeFinish" o = OutputStreamWriteFinishMethodInfo 
ResolvePollableOutputStreamMethod "writeNonblocking" o = PollableOutputStreamWriteNonblockingMethodInfo 
ResolvePollableOutputStreamMethod "writev" o = OutputStreamWritevMethodInfo 
ResolvePollableOutputStreamMethod "writevAll" o = OutputStreamWritevAllMethodInfo 
ResolvePollableOutputStreamMethod "writevAllAsync" o = OutputStreamWritevAllAsyncMethodInfo 
ResolvePollableOutputStreamMethod "writevAllFinish" o = OutputStreamWritevAllFinishMethodInfo 
ResolvePollableOutputStreamMethod "writevAsync" o = OutputStreamWritevAsyncMethodInfo 
ResolvePollableOutputStreamMethod "writevFinish" o = OutputStreamWritevFinishMethodInfo 
ResolvePollableOutputStreamMethod "writevNonblocking" o = PollableOutputStreamWritevNonblockingMethodInfo 
ResolvePollableOutputStreamMethod "getData" o = ObjectGetDataMethodInfo 
ResolvePollableOutputStreamMethod "getProperty" o = ObjectGetPropertyMethodInfo 
ResolvePollableOutputStreamMethod "getQdata" o = ObjectGetQdataMethodInfo 
ResolvePollableOutputStreamMethod "setData" o = ObjectSetDataMethodInfo 
ResolvePollableOutputStreamMethod "setDataFull" o = ObjectSetDataFullMethodInfo 
ResolvePollableOutputStreamMethod "setPending" o = OutputStreamSetPendingMethodInfo 
ResolvePollableOutputStreamMethod "setProperty" o = ObjectSetPropertyMethodInfo 
ResolvePollableOutputStreamMethod l o = MethodResolutionFailed l o :: Type 

canPoll

pollableOutputStreamCanPoll Source #

Arguments

:: (HasCallStack, MonadIO m, IsPollableOutputStream a) 
=> a

stream: a PollableOutputStream.

-> m Bool

Returns: True if stream is pollable, False if not.

Checks if stream is actually pollable. Some classes may implement PollableOutputStream but have only certain instances of that class be pollable. If this method returns False, then the behavior of other PollableOutputStream methods is undefined.

For any given stream, the value returned by this method is constant; a stream cannot switch from pollable to non-pollable or vice versa.

Since: 2.28

createSource

pollableOutputStreamCreateSource Source #

Arguments

:: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) 
=> a

stream: a PollableOutputStream.

-> Maybe b

cancellable: a Cancellable, or Nothing

-> m Source

Returns: a new Source

Creates a Source that triggers when stream can be written, or cancellable is triggered or an error occurs. The callback on the source is of the PollableSourceFunc type.

As with pollableOutputStreamIsWritable, it is possible that the stream may not actually be writable even after the source triggers, so you should use pollableOutputStreamWriteNonblocking rather than outputStreamWrite from the callback.

The behaviour of this method is undefined if pollableOutputStreamCanPoll returns False for stream.

Since: 2.28

isWritable

pollableOutputStreamIsWritable Source #

Arguments

:: (HasCallStack, MonadIO m, IsPollableOutputStream a) 
=> a

stream: a PollableOutputStream.

-> m Bool

Returns: True if stream is writable, False if not. If an error has occurred on stream, this will result in pollableOutputStreamIsWritable returning True, and the next attempt to write will return the error.

Checks if stream can be written.

Note that some stream types may not be able to implement this 100% reliably, and it is possible that a call to outputStreamWrite after this returns True would still block. To guarantee non-blocking behavior, you should always use pollableOutputStreamWriteNonblocking, which will return a IOErrorEnumWouldBlock error rather than blocking.

The behaviour of this method is undefined if pollableOutputStreamCanPoll returns False for stream.

Since: 2.28

writeNonblocking

pollableOutputStreamWriteNonblocking Source #

Arguments

:: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) 
=> a

stream: a PollableOutputStream

-> Maybe ByteString

buffer: a buffer to write data from

-> Maybe b

cancellable: a Cancellable, or Nothing

-> m Int64

Returns: the number of bytes written, or -1 on error (including IOErrorEnumWouldBlock). (Can throw GError)

Attempts to write up to count bytes from buffer to stream, as with outputStreamWrite. If stream is not currently writable, this will immediately return IOErrorEnumWouldBlock, and you can use pollableOutputStreamCreateSource to create a Source that will be triggered when stream is writable.

Note that since this method never blocks, you cannot actually use cancellable to cancel it. However, it will return an error if cancellable has already been cancelled when you call, which may happen if you call this method after a source triggers due to having been cancelled.

Also note that if IOErrorEnumWouldBlock is returned some underlying transports like D/TLS require that you re-send the same buffer and count in the next write call.

The behaviour of this method is undefined if pollableOutputStreamCanPoll returns False for stream.

writevNonblocking

pollableOutputStreamWritevNonblocking Source #

Arguments

:: (HasCallStack, MonadIO m, IsPollableOutputStream a, IsCancellable b) 
=> a

stream: a PollableOutputStream

-> [OutputVector]

vectors: the buffer containing the GOutputVectors to write.

-> Maybe b

cancellable: a Cancellable, or Nothing

-> m (PollableReturn, CSize)

Returns: %gPOLLABLERETURNOK on success, PollableReturnWouldBlock if the stream is not currently writable (and error is *not* set), or PollableReturnFailed if there was an error in which case error will be set. (Can throw GError)

Attempts to write the bytes contained in the nVectors vectors to stream, as with outputStreamWritev. If stream is not currently writable, this will immediately return %gPOLLABLERETURNWOULDBLOCK, and you can use pollableOutputStreamCreateSource to create a Source that will be triggered when stream is writable. error will *not* be set in that case.

Note that since this method never blocks, you cannot actually use cancellable to cancel it. However, it will return an error if cancellable has already been cancelled when you call, which may happen if you call this method after a source triggers due to having been cancelled.

Also note that if PollableReturnWouldBlock is returned some underlying transports like D/TLS require that you re-send the same vectors and nVectors in the next write call.

The behaviour of this method is undefined if pollableOutputStreamCanPoll returns False for stream.

Since: 2.60