Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
- Exported types
- Methods
- clearPending
- close
- closeAsync
- closeFinish
- flush
- flushAsync
- flushFinish
- hasPending
- isClosed
- isClosing
- setPending
- splice
- spliceAsync
- spliceFinish
- write
- writeAll
- writeAllAsync
- writeAllFinish
- writeAsync
- writeBytes
- writeBytesAsync
- writeBytesFinish
- writeFinish
- writev
- writevAll
- writevAllAsync
- writevAllFinish
- writevAsync
- writevFinish
OutputStream
has functions to write to a stream (outputStreamWrite
),
to close a stream (outputStreamClose
) and to flush pending writes
(outputStreamFlush
).
To copy the content of an input stream to an output stream without
manually handling the reads and writes, use outputStreamSplice
.
See the documentation for IOStream
for details of thread safety of
streaming APIs.
All of these functions have async variants too.
Synopsis
- newtype OutputStream = OutputStream (ManagedPtr OutputStream)
- class (GObject o, IsDescendantOf OutputStream o) => IsOutputStream o
- toOutputStream :: (MonadIO m, IsOutputStream o) => o -> m OutputStream
- outputStreamClearPending :: (HasCallStack, MonadIO m, IsOutputStream a) => a -> m ()
- outputStreamClose :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Maybe b -> m ()
- outputStreamCloseAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- outputStreamCloseFinish :: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) => a -> b -> m ()
- outputStreamFlush :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Maybe b -> m ()
- outputStreamFlushAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- outputStreamFlushFinish :: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) => a -> b -> m ()
- outputStreamHasPending :: (HasCallStack, MonadIO m, IsOutputStream a) => a -> m Bool
- outputStreamIsClosed :: (HasCallStack, MonadIO m, IsOutputStream a) => a -> m Bool
- outputStreamIsClosing :: (HasCallStack, MonadIO m, IsOutputStream a) => a -> m Bool
- outputStreamSetPending :: (HasCallStack, MonadIO m, IsOutputStream a) => a -> m ()
- outputStreamSplice :: (HasCallStack, MonadIO m, IsOutputStream a, IsInputStream b, IsCancellable c) => a -> b -> [OutputStreamSpliceFlags] -> Maybe c -> m Int64
- outputStreamSpliceAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsInputStream b, IsCancellable c) => a -> b -> [OutputStreamSpliceFlags] -> Int32 -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- outputStreamSpliceFinish :: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) => a -> b -> m Int64
- outputStreamWrite :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> ByteString -> Maybe b -> m Int64
- outputStreamWriteAll :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> ByteString -> Maybe b -> m Word64
- outputStreamWriteAllAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> ByteString -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- outputStreamWriteAllFinish :: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) => a -> b -> m Word64
- outputStreamWriteAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Maybe ByteString -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- outputStreamWriteBytes :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Bytes -> Maybe b -> m Int64
- outputStreamWriteBytesAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> Bytes -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- outputStreamWriteBytesFinish :: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) => a -> b -> m Int64
- outputStreamWriteFinish :: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) => a -> b -> m Int64
- outputStreamWritev :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> [OutputVector] -> Maybe b -> m Word64
- outputStreamWritevAll :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> [OutputVector] -> Maybe b -> m Word64
- outputStreamWritevAllAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> [OutputVector] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- outputStreamWritevAllFinish :: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) => a -> b -> m Word64
- outputStreamWritevAsync :: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) => a -> [OutputVector] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- outputStreamWritevFinish :: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) => a -> b -> m Word64
Exported types
newtype OutputStream Source #
Memory-managed wrapper type.
Instances
Eq OutputStream Source # | |
Defined in GI.Gio.Objects.OutputStream (==) :: OutputStream -> OutputStream -> Bool # (/=) :: OutputStream -> OutputStream -> Bool # | |
GObject OutputStream Source # | |
Defined in GI.Gio.Objects.OutputStream | |
ManagedPtrNewtype OutputStream Source # | |
Defined in GI.Gio.Objects.OutputStream | |
TypedObject OutputStream Source # | |
Defined in GI.Gio.Objects.OutputStream | |
HasParentTypes OutputStream Source # | |
Defined in GI.Gio.Objects.OutputStream | |
IsGValue (Maybe OutputStream) Source # | Convert |
Defined in GI.Gio.Objects.OutputStream gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe OutputStream -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe OutputStream) # | |
type ParentTypes OutputStream Source # | |
Defined in GI.Gio.Objects.OutputStream |
class (GObject o, IsDescendantOf OutputStream o) => IsOutputStream o Source #
Type class for types which can be safely cast to OutputStream
, for instance with toOutputStream
.
Instances
(GObject o, IsDescendantOf OutputStream o) => IsOutputStream o Source # | |
Defined in GI.Gio.Objects.OutputStream |
toOutputStream :: (MonadIO m, IsOutputStream o) => o -> m OutputStream Source #
Cast to OutputStream
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, clearPending, close, closeAsync, closeFinish, flush, flushAsync, flushFinish, forceFloating, freezeNotify, getv, hasPending, isClosed, isClosing, isFloating, notify, notifyByPspec, ref, refSink, runDispose, splice, spliceAsync, spliceFinish, stealData, stealQdata, thawNotify, unref, watchClosure, write, writeAll, writeAllAsync, writeAllFinish, writeAsync, writeBytes, writeBytesAsync, writeBytesFinish, writeFinish, writev, writevAll, writevAllAsync, writevAllFinish, writevAsync, writevFinish.
Getters
getData, getProperty, getQdata.
Setters
clearPending
outputStreamClearPending Source #
:: (HasCallStack, MonadIO m, IsOutputStream a) | |
=> a |
|
-> m () |
Clears the pending flag on stream
.
close
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m () | (Can throw |
Closes the stream, releasing resources related to it.
Once the stream is closed, all other operations will return IOErrorEnumClosed
.
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 IOErrorEnumClosed
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 Nothing
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnumCancelled
will be returned.
Cancelling a close will still leave the stream closed, but there some streams
can use a faster close that doesn't block to e.g. check errors. On
cancellation (as with any error) there is no guarantee that all written
data will reach the target.
closeAsync
outputStreamCloseAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
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 outputStreamCloseFinish
to get
the result of the operation.
For behaviour details see outputStreamClose
.
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.
closeFinish
outputStreamCloseFinish Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Closes an output stream.
flush
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m () | (Can throw |
Forces a write of all user-space buffered data for the given
stream
. Will block during the operation. Closing the stream will
implicitly cause a flush.
This function is optional for inherited classes.
If cancellable
is not Nothing
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnumCancelled
will be returned.
flushAsync
outputStreamFlushAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Forces an asynchronous write of all user-space buffered data for
the given stream
.
For behaviour details see outputStreamFlush
.
When the operation is finished callback
will be
called. You can then call outputStreamFlushFinish
to get the
result of the operation.
flushFinish
outputStreamFlushFinish Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes flushing an output stream.
hasPending
outputStreamHasPending Source #
:: (HasCallStack, MonadIO m, IsOutputStream a) | |
=> a |
|
-> m Bool | Returns: |
Checks if an output stream has pending actions.
isClosed
:: (HasCallStack, MonadIO m, IsOutputStream a) | |
=> a |
|
-> m Bool |
Checks if an output stream has already been closed.
isClosing
outputStreamIsClosing Source #
:: (HasCallStack, MonadIO m, IsOutputStream a) | |
=> a |
|
-> m Bool |
Checks if an output stream is being closed. This can be used inside e.g. a flush implementation to see if the flush (or other i/o operation) is called from within the closing operation.
Since: 2.24
setPending
outputStreamSetPending Source #
:: (HasCallStack, MonadIO m, IsOutputStream a) | |
=> a |
|
-> m () | (Can throw |
Sets stream
to have actions pending. If the pending flag is
already set or stream
is closed, it will return False
and set
error
.
splice
:: (HasCallStack, MonadIO m, IsOutputStream a, IsInputStream b, IsCancellable c) | |
=> a |
|
-> b |
|
-> [OutputStreamSpliceFlags] |
|
-> Maybe c |
|
-> m Int64 | Returns: a |
Splices an input stream into an output stream.
spliceAsync
outputStreamSpliceAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsInputStream b, IsCancellable c) | |
=> a |
|
-> b |
|
-> [OutputStreamSpliceFlags] |
|
-> Int32 |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Splices a stream asynchronously.
When the operation is finished callback
will be called.
You can then call outputStreamSpliceFinish
to get the
result of the operation.
For the synchronous, blocking version of this function, see
outputStreamSplice
.
spliceFinish
outputStreamSpliceFinish Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Int64 | Returns: a |
Finishes an asynchronous stream splice operation.
write
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> ByteString |
|
-> Maybe b |
|
-> m Int64 | Returns: Number of bytes written, or -1 on error (Can throw |
Tries to write count
bytes from buffer
into the stream. Will block
during the operation.
If count is 0, returns 0 and does nothing. A value of count
larger than G_MAXSSIZE
will cause a IOErrorEnumInvalidArgument
error.
On success, the number of bytes written to the stream is returned.
It is not an error if this is not the same as the requested size, as it
can happen e.g. on a partial I/O error, or if there is not enough
storage in the stream. All writes block until at least one byte
is written or an error occurs; 0 is never returned (unless
count
is 0).
If cancellable
is not Nothing
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnumCancelled
will be returned. If an
operation was partially finished when the operation was cancelled the
partial result will be returned, without an error.
On error -1 is returned and error
is set accordingly.
writeAll
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> ByteString |
|
-> Maybe b |
|
-> m Word64 | (Can throw |
Tries to write count
bytes from buffer
into the stream. Will block
during the operation.
This function is similar to outputStreamWrite
, except it tries to
write as many bytes as requested, only stopping on an error.
On a successful write of count
bytes, True
is returned, and bytesWritten
is set to count
.
If there is an error during the operation False
is returned and error
is set to indicate the error status.
As a special exception to the normal conventions for functions that
use GError
, if this function returns False
(and sets error
) then
bytesWritten
will be set to the number of bytes that were
successfully written before the error was encountered. This
functionality is only available from C. If you need it from another
language then you must write your own loop around
outputStreamWrite
.
writeAllAsync
outputStreamWriteAllAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> ByteString |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Request an asynchronous write of count
bytes from buffer
into
the stream. When the operation is finished callback
will be called.
You can then call outputStreamWriteAllFinish
to get the result of the
operation.
This is the asynchronous version of outputStreamWriteAll
.
Call outputStreamWriteAllFinish
to collect the result.
Any outstanding I/O request with higher priority (lower numerical
value) will be executed before an outstanding request with lower
priority. Default priority is PRIORITY_DEFAULT
.
Note that no copy of buffer
will be made, so it must stay valid
until callback
is called.
Since: 2.44
writeAllFinish
outputStreamWriteAllFinish Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Word64 | (Can throw |
Finishes an asynchronous stream write operation started with
outputStreamWriteAllAsync
.
As a special exception to the normal conventions for functions that
use GError
, if this function returns False
(and sets error
) then
bytesWritten
will be set to the number of bytes that were
successfully written before the error was encountered. This
functionality is only available from C. If you need it from another
language then you must write your own loop around
outputStreamWriteAsync
.
Since: 2.44
writeAsync
outputStreamWriteAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> Maybe ByteString |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Request an asynchronous write of count
bytes from buffer
into
the stream. When the operation is finished callback
will be called.
You can then call outputStreamWriteFinish
to get the result of the
operation.
During an async request no other sync and async calls are allowed,
and will result in IOErrorEnumPending
errors.
A value of count
larger than G_MAXSSIZE
will cause a
IOErrorEnumInvalidArgument
error.
On success, the number of bytes written will be passed to the
callback
. It is not an error if this is not the same as the
requested size, as it can happen e.g. on a partial I/O error,
but generally we try to write as many bytes as requested.
You are guaranteed that this method will never fail with
IOErrorEnumWouldBlock
- if stream
can't accept more data, the
method will just wait until this changes.
Any outstanding I/O request with higher priority (lower numerical
value) will be executed before an outstanding request with lower
priority. Default priority is PRIORITY_DEFAULT
.
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.
For the synchronous, blocking version of this function, see
outputStreamWrite
.
Note that no copy of buffer
will be made, so it must stay valid
until callback
is called. See outputStreamWriteBytesAsync
for a Bytes
version that will automatically hold a reference to
the contents (without copying) for the duration of the call.
writeBytes
outputStreamWriteBytes Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> Bytes |
|
-> Maybe b |
|
-> m Int64 | Returns: Number of bytes written, or -1 on error (Can throw |
A wrapper function for outputStreamWrite
which takes a
Bytes
as input. This can be more convenient for use by language
bindings or in other cases where the refcounted nature of Bytes
is helpful over a bare pointer interface.
However, note that this function may still perform partial writes,
just like outputStreamWrite
. If that occurs, to continue
writing, you will need to create a new Bytes
containing just the
remaining bytes, using bytesNewFromBytes
. Passing the same
Bytes
instance multiple times potentially can result in duplicated
data in the output stream.
writeBytesAsync
outputStreamWriteBytesAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> Bytes |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
This function is similar to outputStreamWriteAsync
, but
takes a Bytes
as input. Due to the refcounted nature of Bytes
,
this allows the stream to avoid taking a copy of the data.
However, note that this function may still perform partial writes,
just like outputStreamWriteAsync
. If that occurs, to continue
writing, you will need to create a new Bytes
containing just the
remaining bytes, using bytesNewFromBytes
. Passing the same
Bytes
instance multiple times potentially can result in duplicated
data in the output stream.
For the synchronous, blocking version of this function, see
outputStreamWriteBytes
.
writeBytesFinish
outputStreamWriteBytesFinish Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Int64 | Returns: a |
Finishes a stream write-from-tBytes
operation.
writeFinish
outputStreamWriteFinish Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Int64 | Returns: a |
Finishes a stream write operation.
writev
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> [OutputVector] |
|
-> Maybe b |
|
-> m Word64 | (Can throw |
Tries to write the bytes contained in the nVectors
vectors
into the
stream. Will block during the operation.
If nVectors
is 0 or the sum of all bytes in vectors
is 0, returns 0 and
does nothing.
On success, the number of bytes written to the stream is returned.
It is not an error if this is not the same as the requested size, as it
can happen e.g. on a partial I/O error, or if there is not enough
storage in the stream. All writes block until at least one byte
is written or an error occurs; 0 is never returned (unless
nVectors
is 0 or the sum of all bytes in vectors
is 0).
If cancellable
is not Nothing
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error IOErrorEnumCancelled
will be returned. If an
operation was partially finished when the operation was cancelled the
partial result will be returned, without an error.
Some implementations of outputStreamWritev
may have limitations on the
aggregate buffer size, and will return IOErrorEnumInvalidArgument
if these
are exceeded. For example, when writing to a local file on UNIX platforms,
the aggregate buffer size must not exceed G_MAXSSIZE
bytes.
Since: 2.60
writevAll
outputStreamWritevAll Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> [OutputVector] |
|
-> Maybe b |
|
-> m Word64 | (Can throw |
Tries to write the bytes contained in the nVectors
vectors
into the
stream. Will block during the operation.
This function is similar to outputStreamWritev
, except it tries to
write as many bytes as requested, only stopping on an error.
On a successful write of all nVectors
vectors, True
is returned, and
bytesWritten
is set to the sum of all the sizes of vectors
.
If there is an error during the operation False
is returned and error
is set to indicate the error status.
As a special exception to the normal conventions for functions that
use GError
, if this function returns False
(and sets error
) then
bytesWritten
will be set to the number of bytes that were
successfully written before the error was encountered. This
functionality is only available from C. If you need it from another
language then you must write your own loop around
outputStreamWrite
.
The content of the individual elements of vectors
might be changed by this
function.
Since: 2.60
writevAllAsync
outputStreamWritevAllAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> [OutputVector] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Request an asynchronous write of the bytes contained in the nVectors
vectors
into
the stream. When the operation is finished callback
will be called.
You can then call outputStreamWritevAllFinish
to get the result of the
operation.
This is the asynchronous version of outputStreamWritevAll
.
Call outputStreamWritevAllFinish
to collect the result.
Any outstanding I/O request with higher priority (lower numerical
value) will be executed before an outstanding request with lower
priority. Default priority is PRIORITY_DEFAULT
.
Note that no copy of vectors
will be made, so it must stay valid
until callback
is called. The content of the individual elements
of vectors
might be changed by this function.
Since: 2.60
writevAllFinish
outputStreamWritevAllFinish Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Word64 | (Can throw |
Finishes an asynchronous stream write operation started with
outputStreamWritevAllAsync
.
As a special exception to the normal conventions for functions that
use GError
, if this function returns False
(and sets error
) then
bytesWritten
will be set to the number of bytes that were
successfully written before the error was encountered. This
functionality is only available from C. If you need it from another
language then you must write your own loop around
outputStreamWritevAsync
.
Since: 2.60
writevAsync
outputStreamWritevAsync Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsCancellable b) | |
=> a |
|
-> [OutputVector] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Request an asynchronous write of the bytes contained in nVectors
vectors
into
the stream. When the operation is finished callback
will be called.
You can then call outputStreamWritevFinish
to get the result of the
operation.
During an async request no other sync and async calls are allowed,
and will result in IOErrorEnumPending
errors.
On success, the number of bytes written will be passed to the
callback
. It is not an error if this is not the same as the
requested size, as it can happen e.g. on a partial I/O error,
but generally we try to write as many bytes as requested.
You are guaranteed that this method will never fail with
IOErrorEnumWouldBlock
— if stream
can't accept more data, the
method will just wait until this changes.
Any outstanding I/O request with higher priority (lower numerical
value) will be executed before an outstanding request with lower
priority. Default priority is PRIORITY_DEFAULT
.
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.
For the synchronous, blocking version of this function, see
outputStreamWritev
.
Note that no copy of vectors
will be made, so it must stay valid
until callback
is called.
Since: 2.60
writevFinish
outputStreamWritevFinish Source #
:: (HasCallStack, MonadIO m, IsOutputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Word64 | (Can throw |
Finishes a stream writev operation.
Since: 2.60