[−][src]Trait gio::OutputStreamExt
Trait containing all OutputStream methods.
Implementors
FileOutputStream, FilterOutputStream, MemoryOutputStream, OutputStream, PollableOutputStream, UnixOutputStream
Required methods
fn clear_pending(&self)
Clears the pending flag on self.
fn close<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<(), Error>
&self,
cancellable: Option<&P>
) -> Result<(), Error>
Closes the stream, releasing resources related to it.
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 None, 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 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.
cancellable
optional cancellable object
Returns
true on success, false on failure
fn close_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
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 OutputStreamExt::close_finish to get
the result of the operation.
For behaviour details see OutputStreamExt::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
callback to call when the request is satisfied
user_data
the data to pass to callback function
fn close_async_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
fn flush<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<(), Error>
&self,
cancellable: Option<&P>
) -> Result<(), Error>
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 None, 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.
cancellable
optional cancellable object
Returns
true on success, false on error
fn flush_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
Forces an asynchronous write of all user-space buffered data for
the given self.
For behaviour details see OutputStreamExt::flush.
When the operation is finished callback will be
called. You can then call OutputStreamExt::flush_finish to get the
result of the operation.
io_priority
the io priority of the request.
cancellable
optional Cancellable object, None to ignore.
callback
a GAsyncReadyCallback to call when the request is satisfied
user_data
the data to pass to callback function
fn flush_async_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
fn has_pending(&self) -> bool
fn is_closed(&self) -> bool
Checks if an output stream has already been closed.
Returns
true if self is closed. false otherwise.
fn is_closing(&self) -> 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.
Returns
true if self is being closed. false otherwise.
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.
fn splice<P: IsA<InputStream>, Q: IsA<Cancellable>>(
&self,
source: &P,
flags: OutputStreamSpliceFlags,
cancellable: Option<&Q>
) -> Result<isize, Error>
&self,
source: &P,
flags: OutputStreamSpliceFlags,
cancellable: Option<&Q>
) -> Result<isize, Error>
Splices an input stream into an output stream.
source
a InputStream.
flags
a set of OutputStreamSpliceFlags.
cancellable
optional Cancellable object, None to ignore.
Returns
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.
fn splice_async<P: IsA<InputStream>, Q: IsA<Cancellable>, R: FnOnce(Result<isize, Error>) + Send + 'static>(
&self,
source: &P,
flags: OutputStreamSpliceFlags,
io_priority: Priority,
cancellable: Option<&Q>,
callback: R
)
&self,
source: &P,
flags: OutputStreamSpliceFlags,
io_priority: Priority,
cancellable: Option<&Q>,
callback: R
)
Splices a stream asynchronously.
When the operation is finished callback will be called.
You can then call OutputStreamExt::splice_finish to get the
result of the operation.
For the synchronous, blocking version of this function, see
OutputStreamExt::splice.
source
a InputStream.
flags
a set of OutputStreamSpliceFlags.
io_priority
the io priority of the request.
cancellable
optional Cancellable object, None to ignore.
callback
a GAsyncReadyCallback.
user_data
user data passed to callback.
fn splice_async_future<P: IsA<InputStream> + Clone + 'static>(
&self,
source: &P,
flags: OutputStreamSpliceFlags,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>
&self,
source: &P,
flags: OutputStreamSpliceFlags,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>
fn write<P: IsA<Cancellable>>(
&self,
buffer: &[u8],
cancellable: Option<&P>
) -> Result<isize, Error>
&self,
buffer: &[u8],
cancellable: Option<&P>
) -> Result<isize, Error>
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 IOErrorEnum::InvalidArgument 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 None, 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. 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.
buffer
the buffer containing the data to write.
count
the number of bytes to write
cancellable
optional cancellable object
Returns
Number of bytes written, or -1 on error
fn write_bytes<P: IsA<Cancellable>>(
&self,
bytes: &Bytes,
cancellable: Option<&P>
) -> Result<isize, Error>
&self,
bytes: &Bytes,
cancellable: Option<&P>
) -> Result<isize, Error>
A wrapper function for OutputStreamExt::write which takes a
glib::Bytes as input. This can be more convenient for use by language
bindings or in other cases where the refcounted nature of glib::Bytes
is helpful over a bare pointer interface.
However, note that this function may still perform partial writes,
just like OutputStreamExt::write. If that occurs, to continue
writing, you will need to create a new glib::Bytes containing just the
remaining bytes, using glib::Bytes::new_from_bytes. Passing the same
glib::Bytes instance multiple times potentially can result in duplicated
data in the output stream.
bytes
the glib::Bytes to write
cancellable
optional cancellable object
Returns
Number of bytes written, or -1 on error
fn write_bytes_async<P: IsA<Cancellable>, Q: FnOnce(Result<isize, Error>) + Send + 'static>(
&self,
bytes: &Bytes,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
&self,
bytes: &Bytes,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
This function is similar to OutputStream::write_async, but
takes a glib::Bytes as input. Due to the refcounted nature of glib::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 OutputStream::write_async. If that occurs, to continue
writing, you will need to create a new glib::Bytes containing just the
remaining bytes, using glib::Bytes::new_from_bytes. Passing the same
glib::Bytes instance multiple times potentially can result in duplicated
data in the output stream.
For the synchronous, blocking version of this function, see
OutputStreamExt::write_bytes.
bytes
The bytes to write
io_priority
the io priority of the request.
cancellable
optional Cancellable object, None to ignore.
callback
callback to call when the request is satisfied
user_data
the data to pass to callback function
fn write_bytes_async_future(
&self,
bytes: &Bytes,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>
&self,
bytes: &Bytes,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>
Implementors
impl<O: IsA<OutputStream>> OutputStreamExt for O[src]
fn clear_pending(&self)[src]
fn close<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<(), Error>[src]
&self,
cancellable: Option<&P>
) -> Result<(), Error>
fn close_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)[src]
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
fn close_async_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>[src]
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
fn flush<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<(), Error>[src]
&self,
cancellable: Option<&P>
) -> Result<(), Error>
fn flush_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)[src]
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
fn flush_async_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>[src]
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
fn has_pending(&self) -> bool[src]
fn is_closed(&self) -> bool[src]
fn is_closing(&self) -> bool[src]
fn set_pending(&self) -> Result<(), Error>[src]
fn splice<P: IsA<InputStream>, Q: IsA<Cancellable>>(
&self,
source: &P,
flags: OutputStreamSpliceFlags,
cancellable: Option<&Q>
) -> Result<isize, Error>[src]
&self,
source: &P,
flags: OutputStreamSpliceFlags,
cancellable: Option<&Q>
) -> Result<isize, Error>
fn splice_async<P: IsA<InputStream>, Q: IsA<Cancellable>, R: FnOnce(Result<isize, Error>) + Send + 'static>(
&self,
source: &P,
flags: OutputStreamSpliceFlags,
io_priority: Priority,
cancellable: Option<&Q>,
callback: R
)[src]
&self,
source: &P,
flags: OutputStreamSpliceFlags,
io_priority: Priority,
cancellable: Option<&Q>,
callback: R
)
fn splice_async_future<P: IsA<InputStream> + Clone + 'static>(
&self,
source: &P,
flags: OutputStreamSpliceFlags,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>[src]
&self,
source: &P,
flags: OutputStreamSpliceFlags,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>
fn write<P: IsA<Cancellable>>(
&self,
buffer: &[u8],
cancellable: Option<&P>
) -> Result<isize, Error>[src]
&self,
buffer: &[u8],
cancellable: Option<&P>
) -> Result<isize, Error>
fn write_bytes<P: IsA<Cancellable>>(
&self,
bytes: &Bytes,
cancellable: Option<&P>
) -> Result<isize, Error>[src]
&self,
bytes: &Bytes,
cancellable: Option<&P>
) -> Result<isize, Error>
fn write_bytes_async<P: IsA<Cancellable>, Q: FnOnce(Result<isize, Error>) + Send + 'static>(
&self,
bytes: &Bytes,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)[src]
&self,
bytes: &Bytes,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
fn write_bytes_async_future(
&self,
bytes: &Bytes,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>[src]
&self,
bytes: &Bytes,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>