It derives from <GObject>.
<GOutputStream> is a base class for
implementing streaming output.
It has functions to write to a stream (output-stream:write), to close a stream
(output-stream:close?) and to flush
pending writes (output-stream:flush?).
To copy the content of an input stream to an output stream without
manually handling the reads and writes, use output-stream:splice.
See the documentation for <GIOStream> for details
of thread safety of streaming APIs.
All of these functions have async variants too.
All classes derived from <GOutputStream>
should implement synchronous writing, splicing, flushing and
closing streams, but may implement asynchronous versions.
parent-instanceClears the pending flag on self.
Passed: a <GOutputStream>.
output stream
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 output-stream:close-finish? to get the result of the
operation.
For behaviour details see output-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.
Passed: a <GOutputStream>.
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional cancellable object
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback function
Closes an output stream.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t if stream was successfully closed, #f otherwise.
Closes the stream, releasing resources related to it.
Once the stream is closed, all other operations will return
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 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 #f, then the operation can be
cancelled by triggering the cancellable object from another thread. If
the operation was cancelled, the error
cancelled 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.
Passed: a <GOutputStream>.
Passed, or left out: a <GCancellable>, or
#f.
optional cancellable object
Returned: a boolean.
#t on success, #f on failure
Forces an asynchronous write of all user-space buffered data for the
given self. For behaviour details see output-stream:flush?.
When the operation is finished callback will be called. You can
then call output-stream:flush-finish? to get the result of the
operation.
Passed: a <GOutputStream>.
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback function
Finishes flushing an output stream.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
a GAsyncResult.
Returned: a boolean.
#t if flush operation succeeded, #f otherwise.
Forces a write of all user-space buffered data for the given self. Will block during the operation. Closing the stream will implicitly cause a flush.
This function is optional for inherited classes.
If cancellable is not #f, then the operation can be
cancelled by triggering the cancellable object from another thread. If
the operation was cancelled, the error
cancelled will be returned.
Passed: a <GOutputStream>.
Passed, or left out: a <GCancellable>, or
#f.
optional cancellable object
Returned: a boolean.
#t on success, #f on error
Checks if an output stream has pending actions.
Passed: a <GOutputStream>.
Returned: a boolean.
#t if self has pending actions.
Checks if an output stream has already been closed.
Passed: a <GOutputStream>.
Returned: a boolean.
#t if self is closed. #f otherwise.
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.
Passed: a <GOutputStream>.
Returned: a boolean.
#t if self is being closed. #f otherwise.
Sets self to have actions pending. If the pending flag is already
set or self is closed, it will return #f and set
error.
Passed: a <GOutputStream>.
Returned: a boolean.
#t if pending was previously unset and is now set.
Splices an input stream into an output stream.
Passed: a <GOutputStream>.
Passed: a <GInputStream>.
Passed: a
<GOutputStreamSpliceFlags>, or a
list of its symbols, or one of them.
a set of
<GOutputStreamSpliceFlags>.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Returned: a 64-bit integer.
a gssize containing the size of the data spliced, or -1 if an
error occurred. Note that if the number of bytes spliced is greater
than G_MAXSSIZE, then that will be returned, and there is no way
to determine the actual number of bytes spliced.
Splices a stream asynchronously. When the operation is finished
callback will be called. You can then call
output-stream:splice-finish to
get the result of the operation.
For the synchronous, blocking version of this function, see
output-stream:splice.
Passed: a <GOutputStream>.
Passed: a <GInputStream>.
Passed: a
<GOutputStreamSpliceFlags>, or a
list of its symbols, or one of them.
a set of
<GOutputStreamSpliceFlags>.
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback function
Finishes an asynchronous stream splice operation.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a 64-bit integer.
a gssize of the number of bytes spliced. Note that if the number
of bytes spliced is greater than G_MAXSSIZE, then that will be
returned, and there is no way to determine the actual number of bytes
spliced.
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
invalid-argument 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 #f, then the operation can be
cancelled by triggering the cancellable object from another thread. If
the operation was cancelled, the error
cancelled 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.
Passed: a <GOutputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit integer.
the buffer containing the data to write.
Passed, or left out: a <GCancellable>, or
#f.
optional cancellable object
Returned: a 64-bit integer.
Number of bytes written, or -1 on error
Not passed: guile-gi gives the length of buffer.
the number of bytes to write
Tries to write count bytes from buffer into the stream. Will block during the operation.
This function is similar to output-stream:write, except it tries to write as many bytes as
requested, only stopping on an error.
On a successful write of count bytes, #t is returned, and
bytes-written is set to count.
If there is an error during the operation #f 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 #f
(and sets error) then bytes-written 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
output-stream:write.
Passed: a <GOutputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit integer.
the buffer containing the data to write.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Returned: a boolean.
#t on success, #f if there was an error
Returned: an unsigned 64-bit integer.
location to store the number of bytes that was written to the stream
Not passed: guile-gi gives the length of buffer.
the number of bytes to write
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 output-stream:write-all-finish to get the result of
the operation.
This is the asynchronous version of output-stream:write-all.
Call output-stream:write-all-finish 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 G_PRIORITY_DEFAULT.
Note that no copy of buffer will be made, so it must stay valid until callback is called.
Passed: a <GOutputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit integer.
the buffer containing the data to write
Passed: a 32-bit integer.
the io priority of the request
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi gives the length of buffer.
the number of bytes to write
Not passed: guile-gi supplies it.
the data to pass to callback function
Finishes an asynchronous stream write operation started with
output-stream:write-all-async.
As a special exception to the normal conventions for functions that use
<GError>, if this function returns #f
(and sets error) then bytes-written 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
output-stream:write-async.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t on success, #f if there was an error
Returned: an unsigned 64-bit integer.
location to store the number of bytes that was written to the stream
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 output-stream:write-finish to get the result of the
operation.
During an async request no other sync and async calls are allowed, and
will result in pending errors.
A value of count larger than G_MAXSSIZE will cause a
invalid-argument 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
would-block - if self 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 G_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
output-stream:write.
Note that no copy of buffer will be made, so it must stay valid
until callback is called. See output-stream:write-bytes-async for a
<GBytes> version that will automatically hold a
reference to the contents (without copying) for the duration of the
call.
Passed: a <GOutputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit integer.
the buffer containing the data to write.
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi gives the length of buffer.
the number of bytes to write
Not passed: guile-gi supplies it.
the data to pass to callback function
A wrapper function for output-stream:write which takes a
<GBytes> as input. This can be more convenient
for use by language bindings or in other cases where the refcounted
nature of <GBytes> is helpful over a bare
pointer interface.
However, note that this function may still perform partial writes, just
like output-stream:write. If that
occurs, to continue writing, you will need to create a new
<GBytes> containing just the remaining bytes,
using bytes:new-from-bytes.
Passing the same <GBytes> instance multiple
times potentially can result in duplicated data in the output stream.
Passed: a <GOutputStream>.
Passed: a <GBytes>.
the <GBytes> to write
Passed, or left out: a <GCancellable>, or
#f.
optional cancellable object
Returned: a 64-bit integer.
Number of bytes written, or -1 on error
This function is similar to output-stream:write-async, but takes a
<GBytes> as input. Due to the refcounted
nature of <GBytes>, this allows the stream to
avoid taking a copy of the data.
However, note that this function may still perform partial writes, just
like output-stream:write-async.
If that occurs, to continue writing, you will need to create a new
<GBytes> containing just the remaining bytes,
using bytes:new-from-bytes.
Passing the same <GBytes> instance multiple
times potentially can result in duplicated data in the output stream.
For the synchronous, blocking version of this function, see
output-stream:write-bytes.
Passed: a <GOutputStream>.
Passed: a <GBytes>.
The bytes to write
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback function
Finishes a stream write-from-<GBytes>
operation.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a 64-bit integer.
a gssize containing the number of bytes written to the stream.
Finishes a stream write operation.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a 64-bit integer.
a gssize containing the number of bytes written to the stream.
Finishes an asynchronous stream write operation started with
g_output_stream_writev_all_async().
As a special exception to the normal conventions for functions that use
<GError>, if this function returns #f
(and sets error) then bytes-written 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
g_output_stream_writev_async().
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t on success, #f if there was an error
Returned: an unsigned 64-bit integer.
location to store the number of bytes that were written to the stream
Finishes a stream writev operation.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t on success, #f if there was an error
Returned: an unsigned 64-bit integer.
location to store the number of bytes that were written to the stream
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 output-stream:close-finish? to get the result of the
operation.
For behaviour details see output-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.
To override it in a new class, give register-type #:vfuncs
`((close-async . ,procedure)). The procedure is called as
(procedure self io-priority cancellable callback user-data).
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional cancellable object
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback function
Closes an output stream.
To override it in a new class, give register-type #:vfuncs
`((close-finish . ,procedure)). The procedure is called as
(procedure self result) ⇒ %return.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t if stream was successfully closed, #f otherwise.
To override it in a new class, give register-type #:vfuncs
`((close-fn . ,procedure)). The procedure is called as
(procedure self cancellable) ⇒ %return.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed, or left out: a <GCancellable>, or
#f.
Returned: a boolean.
Forces a write of all user-space buffered data for the given self. Will block during the operation. Closing the stream will implicitly cause a flush.
This function is optional for inherited classes.
If cancellable is not #f, then the operation can be
cancelled by triggering the cancellable object from another thread. If
the operation was cancelled, the error
cancelled will be returned.
To override it in a new class, give register-type #:vfuncs
`((flush . ,procedure)). The procedure is called as (procedure
self cancellable) ⇒ %return.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed, or left out: a <GCancellable>, or
#f.
optional cancellable object
Returned: a boolean.
#t on success, #f on error
Forces an asynchronous write of all user-space buffered data for the
given self. For behaviour details see output-stream:flush?.
When the operation is finished callback will be called. You can
then call output-stream:flush-finish? to get the result of the
operation.
To override it in a new class, give register-type #:vfuncs
`((flush-async . ,procedure)). The procedure is called as
(procedure self io-priority cancellable callback user-data).
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback function
Finishes flushing an output stream.
To override it in a new class, give register-type #:vfuncs
`((flush-finish . ,procedure)). The procedure is called as
(procedure self result) ⇒ %return.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
a GAsyncResult.
Returned: a boolean.
#t if flush operation succeeded, #f otherwise.
Splices an input stream into an output stream.
To override it in a new class, give register-type #:vfuncs
`((splice . ,procedure)). The procedure is called as (procedure
self source flags cancellable) ⇒ %return.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a <GInputStream>.
Passed: a
<GOutputStreamSpliceFlags>, or a
list of its symbols, or one of them.
a set of
<GOutputStreamSpliceFlags>.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Returned: a 64-bit integer.
a gssize containing the size of the data spliced, or -1 if an
error occurred. Note that if the number of bytes spliced is greater
than G_MAXSSIZE, then that will be returned, and there is no way
to determine the actual number of bytes spliced.
Splices a stream asynchronously. When the operation is finished
callback will be called. You can then call
output-stream:splice-finish to
get the result of the operation.
For the synchronous, blocking version of this function, see
output-stream:splice.
To override it in a new class, give register-type #:vfuncs
`((splice-async . ,procedure)). The procedure is called as
(procedure self source flags io-priority cancellable callback
user-data).
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a <GInputStream>.
Passed: a
<GOutputStreamSpliceFlags>, or a
list of its symbols, or one of them.
a set of
<GOutputStreamSpliceFlags>.
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback function
Finishes an asynchronous stream splice operation.
To override it in a new class, give register-type #:vfuncs
`((splice-finish . ,procedure)). The procedure is called as
(procedure self result) ⇒ %return.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a 64-bit integer.
a gssize of the number of bytes spliced. Note that if the number
of bytes spliced is greater than G_MAXSSIZE, then that will be
returned, and there is no way to determine the actual number of bytes
spliced.
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 output-stream:write-finish to get the result of the
operation.
During an async request no other sync and async calls are allowed, and
will result in pending errors.
A value of count larger than G_MAXSSIZE will cause a
invalid-argument 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
would-block - if self 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 G_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
output-stream:write.
Note that no copy of buffer will be made, so it must stay valid
until callback is called. See output-stream:write-bytes-async for a
<GBytes> version that will automatically hold a
reference to the contents (without copying) for the duration of the
call.
To override it in a new class, give register-type #:vfuncs
`((write-async . ,procedure)). The procedure is called as
(procedure self buffer io-priority cancellable callback
user-data).
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit
integer, or #f.
the buffer containing the data to write.
Passed: a 32-bit integer.
the io priority of the request.
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore.
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi gives the length of buffer.
the number of bytes to write
Not passed: guile-gi supplies it.
the data to pass to callback function
Finishes a stream write operation.
To override it in a new class, give register-type #:vfuncs
`((write-finish . ,procedure)). The procedure is called as
(procedure self result) ⇒ %return.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a 64-bit integer.
a gssize containing the number of bytes written to the stream.
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
invalid-argument 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 #f, then the operation can be
cancelled by triggering the cancellable object from another thread. If
the operation was cancelled, the error
cancelled 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.
To override it in a new class, give register-type #:vfuncs
`((write-fn . ,procedure)). The procedure is called as
(procedure self buffer cancellable) ⇒ %return.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a bytevector, or a list or vector, each an unsigned 8-bit
integer, or #f.
the buffer containing the data to write.
Passed, or left out: a <GCancellable>, or
#f.
optional cancellable object
Returned: a 64-bit integer.
Number of bytes written, or -1 on error
Not passed: guile-gi gives the length of buffer.
the number of bytes to write
Finishes a stream writev operation.
To override it in a new class, give register-type #:vfuncs
`((writev-finish . ,procedure)). The procedure is called as
(procedure self result) ⇒ %return bytes-written.
Passed: the class whose implementation to call:
<GOutputStream>, or a class that derives from
it, or its GType number.
Passed: a <GOutputStream>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t on success, #f if there was an error
Returned: an unsigned 64-bit integer.
location to store the number of bytes that were written to the stream