Trait gio::prelude::OutputStreamExtManual
source · pub trait OutputStreamExtManual: Sealed + IsA<OutputStream> + Sized {
// Provided methods
fn write_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + 'static, C: IsA<Cancellable>>(
&self,
buffer: B,
io_priority: Priority,
cancellable: Option<&C>,
callback: Q
) { ... }
fn write_all<C: IsA<Cancellable>>(
&self,
buffer: &[u8],
cancellable: Option<&C>
) -> Result<(usize, Option<Error>), Error> { ... }
fn write_all_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option<Error>), (B, Error)>) + 'static, C: IsA<Cancellable>>(
&self,
buffer: B,
io_priority: Priority,
cancellable: Option<&C>,
callback: Q
) { ... }
fn write_future<B: AsRef<[u8]> + Send + 'static>(
&self,
buffer: B,
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(B, usize), (B, Error)>> + 'static>> { ... }
fn write_all_future<B: AsRef<[u8]> + Send + 'static>(
&self,
buffer: B,
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(B, usize, Option<Error>), (B, Error)>> + 'static>> { ... }
fn writev(
&self,
vectors: &[OutputVector<'_>],
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<usize, Error> { ... }
fn writev_async<B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec<B>, usize), (Vec<B>, Error)>) + 'static>(
&self,
vectors: impl IntoIterator<Item = B> + 'static,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn writev_future<B: AsRef<[u8]> + Send + 'static>(
&self,
vectors: impl IntoIterator<Item = B> + 'static,
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(Vec<B>, usize), (Vec<B>, Error)>> + 'static>> { ... }
fn writev_all(
&self,
vectors: &[OutputVector<'_>],
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(usize, Option<Error>), Error> { ... }
fn writev_all_async<B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec<B>, usize, Option<Error>), (Vec<B>, Error)>) + 'static>(
&self,
vectors: impl IntoIterator<Item = B> + 'static,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
) { ... }
fn writev_all_future<B: AsRef<[u8]> + Send + 'static>(
&self,
vectors: impl IntoIterator<Item = B> + 'static,
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(Vec<B>, usize, Option<Error>), (Vec<B>, Error)>> + 'static>> { ... }
fn into_write(self) -> OutputStreamWrite<Self> ⓘ
where Self: IsA<OutputStream> { ... }
}
Provided Methods§
sourcefn write_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + 'static, C: IsA<Cancellable>>(
&self,
buffer: B,
io_priority: Priority,
cancellable: Option<&C>,
callback: Q
)
fn write_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + 'static, C: IsA<Cancellable>>( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q )
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 g_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 IOErrorEnum::Pending
errors.
A value of count
larger than G_MAXSSIZE
will cause a
IOErrorEnum::InvalidArgument
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
IOErrorEnum::WouldBlock
- 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
OutputStreamExt::write()
.
Note that no copy of buffer
will be made, so it must stay valid
until callback
is called. See OutputStreamExt::write_bytes_async()
for a glib::Bytes
version that will automatically hold a reference to
the contents (without copying) for the duration of the call.
buffer
the buffer containing the data to write.
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
sourcefn write_all<C: IsA<Cancellable>>(
&self,
buffer: &[u8],
cancellable: Option<&C>
) -> Result<(usize, Option<Error>), Error>
fn write_all<C: IsA<Cancellable>>( &self, buffer: &[u8], cancellable: Option<&C> ) -> Result<(usize, Option<Error>), Error>
Tries to write count
bytes from buffer
into the stream. Will block
during the operation.
This function is similar to OutputStreamExt::write()
, 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 bytes_written
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 glib::Error
, if this function returns false
(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
OutputStreamExt::write()
.
buffer
the buffer containing the data to write.
cancellable
optional Cancellable
object, None
to ignore.
Returns
true
on success, false
if there was an error
bytes_written
location to store the number of bytes that was written to the stream
sourcefn write_all_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option<Error>), (B, Error)>) + 'static, C: IsA<Cancellable>>(
&self,
buffer: B,
io_priority: Priority,
cancellable: Option<&C>,
callback: Q
)
fn write_all_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option<Error>), (B, Error)>) + 'static, C: IsA<Cancellable>>( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q )
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 g_output_stream_write_all_finish()
to get the result of the
operation.
This is the asynchronous version of OutputStreamExtManual::write_all()
.
Call g_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.
buffer
the buffer containing the data to write
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
fn write_future<B: AsRef<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority ) -> Pin<Box<dyn Future<Output = Result<(B, usize), (B, Error)>> + 'static>>
fn write_all_future<B: AsRef<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority ) -> Pin<Box<dyn Future<Output = Result<(B, usize, Option<Error>), (B, Error)>> + 'static>>
sourcefn writev(
&self,
vectors: &[OutputVector<'_>],
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<usize, Error>
fn writev( &self, vectors: &[OutputVector<'_>], cancellable: Option<&impl IsA<Cancellable>> ) -> Result<usize, Error>
v2_60
only.Tries to write the bytes contained in the n_vectors
vectors
into the
stream. Will block during the operation.
If n_vectors
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
n_vectors
is 0 or the sum of all bytes in vectors
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.
Some implementations of OutputStreamExtManual::writev()
may have limitations on the
aggregate buffer size, and will return IOErrorEnum::InvalidArgument
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.
vectors
the buffer containing the GOutputVectors
to write.
cancellable
optional cancellable object
Returns
true
on success, false
if there was an error
bytes_written
location to store the number of bytes that were written to the stream
sourcefn writev_async<B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec<B>, usize), (Vec<B>, Error)>) + 'static>(
&self,
vectors: impl IntoIterator<Item = B> + 'static,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn writev_async<B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec<B>, usize), (Vec<B>, Error)>) + 'static>( &self, vectors: impl IntoIterator<Item = B> + 'static, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
v2_60
only.Request an asynchronous write of the bytes contained in n_vectors
vectors
into
the stream. When the operation is finished callback
will be called.
You can then call g_output_stream_writev_finish()
to get the result of the
operation.
During an async request no other sync and async calls are allowed,
and will result in IOErrorEnum::Pending
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
IOErrorEnum::WouldBlock
— 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
OutputStreamExtManual::writev()
.
Note that no copy of vectors
will be made, so it must stay valid
until callback
is called.
vectors
the buffer containing the GOutputVectors
to write.
io_priority
the I/O priority of the request.
cancellable
optional Cancellable
object, None
to ignore.
callback
a GAsyncReadyCallback
to call when the request is satisfied
sourcefn writev_future<B: AsRef<[u8]> + Send + 'static>(
&self,
vectors: impl IntoIterator<Item = B> + 'static,
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(Vec<B>, usize), (Vec<B>, Error)>> + 'static>>
fn writev_future<B: AsRef<[u8]> + Send + 'static>( &self, vectors: impl IntoIterator<Item = B> + 'static, io_priority: Priority ) -> Pin<Box<dyn Future<Output = Result<(Vec<B>, usize), (Vec<B>, Error)>> + 'static>>
v2_60
only.sourcefn writev_all(
&self,
vectors: &[OutputVector<'_>],
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(usize, Option<Error>), Error>
fn writev_all( &self, vectors: &[OutputVector<'_>], cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(usize, Option<Error>), Error>
v2_60
only.Tries to write the bytes contained in the n_vectors
vectors
into the
stream. Will block during the operation.
This function is similar to OutputStreamExtManual::writev()
, except it tries to
write as many bytes as requested, only stopping on an error.
On a successful write of all n_vectors
vectors, true
is returned, and
bytes_written
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 glib::Error
, if this function returns false
(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
OutputStreamExt::write()
.
The content of the individual elements of vectors
might be changed by this
function.
vectors
the buffer containing the GOutputVectors
to write.
cancellable
optional Cancellable
object, None
to ignore.
Returns
true
on success, false
if there was an error
bytes_written
location to store the number of bytes that were written to the stream
sourcefn writev_all_async<B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec<B>, usize, Option<Error>), (Vec<B>, Error)>) + 'static>(
&self,
vectors: impl IntoIterator<Item = B> + 'static,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P
)
fn writev_all_async<B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec<B>, usize, Option<Error>), (Vec<B>, Error)>) + 'static>( &self, vectors: impl IntoIterator<Item = B> + 'static, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
v2_60
only.Request an asynchronous write of the bytes contained in the n_vectors
vectors
into
the stream. When the operation is finished callback
will be called.
You can then call g_output_stream_writev_all_finish()
to get the result of the
operation.
This is the asynchronous version of OutputStreamExtManual::writev_all()
.
Call g_output_stream_writev_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 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.
vectors
the buffer containing the GOutputVectors
to write.
io_priority
the I/O priority of the request
cancellable
optional Cancellable
object, None
to ignore
callback
a GAsyncReadyCallback
to call when the request is satisfied
sourcefn writev_all_future<B: AsRef<[u8]> + Send + 'static>(
&self,
vectors: impl IntoIterator<Item = B> + 'static,
io_priority: Priority
) -> Pin<Box<dyn Future<Output = Result<(Vec<B>, usize, Option<Error>), (Vec<B>, Error)>> + 'static>>
fn writev_all_future<B: AsRef<[u8]> + Send + 'static>( &self, vectors: impl IntoIterator<Item = B> + 'static, io_priority: Priority ) -> Pin<Box<dyn Future<Output = Result<(Vec<B>, usize, Option<Error>), (Vec<B>, Error)>> + 'static>>
v2_60
only.