pub trait PollableOutputStreamExtManual: IsA<PollableOutputStream> {
// Provided methods
fn create_source<F, C>(
&self,
cancellable: Option<&C>,
name: Option<&str>,
priority: Priority,
func: F,
) -> Source
where F: FnMut(&Self) -> ControlFlow + 'static,
C: IsA<Cancellable> { ... }
fn create_source_future<C: IsA<Cancellable>>(
&self,
cancellable: Option<&C>,
priority: Priority,
) -> Pin<Box<dyn Future<Output = ()> + 'static>> { ... }
fn create_source_stream<C: IsA<Cancellable>>(
&self,
cancellable: Option<&C>,
priority: Priority,
) -> Pin<Box<dyn Stream<Item = ()> + 'static>> { ... }
fn writev_nonblocking(
&self,
vectors: &[OutputVector<'_>],
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(PollableReturn, usize), Error> { ... }
fn into_async_write(self) -> Result<OutputStreamAsyncWrite<Self>, Self>
where Self: IsA<PollableOutputStream> { ... }
}
Provided Methods§
Sourcefn create_source<F, C>(
&self,
cancellable: Option<&C>,
name: Option<&str>,
priority: Priority,
func: F,
) -> Source
fn create_source<F, C>( &self, cancellable: Option<&C>, name: Option<&str>, priority: Priority, func: F, ) -> Source
Creates a #GSource that triggers when @self can be written, or @cancellable is triggered or an error occurs. The callback on the source is of the #GPollableSourceFunc type.
As with g_pollable_output_stream_is_writable(), it is possible that the stream may not actually be writable even after the source triggers, so you should use g_pollable_output_stream_write_nonblocking() rather than g_output_stream_write() from the callback.
The behaviour of this method is undefined if
g_pollable_output_stream_can_poll() returns false
for @self.
§cancellable
a #GCancellable, or None
§Returns
a new #GSource
fn create_source_future<C: IsA<Cancellable>>( &self, cancellable: Option<&C>, priority: Priority, ) -> Pin<Box<dyn Future<Output = ()> + 'static>>
fn create_source_stream<C: IsA<Cancellable>>( &self, cancellable: Option<&C>, priority: Priority, ) -> Pin<Box<dyn Stream<Item = ()> + 'static>>
Sourcefn writev_nonblocking(
&self,
vectors: &[OutputVector<'_>],
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(PollableReturn, usize), Error>
Available on crate feature v2_60
only.
fn writev_nonblocking( &self, vectors: &[OutputVector<'_>], cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(PollableReturn, usize), Error>
v2_60
only.Attempts to write the bytes contained in the @n_vectors @vectors to @self, as with g_output_stream_writev(). If @self is not currently writable, this will immediately return %@G_POLLABLE_RETURN_WOULD_BLOCK, and you can use g_pollable_output_stream_create_source() to create a #GSource that will be triggered when @self 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 PollableReturn::WouldBlock
is returned some underlying
transports like D/TLS require that you re-send the same @vectors and
@n_vectors in the next write call.
The behaviour of this method is undefined if
g_pollable_output_stream_can_poll() returns false
for @self.
§vectors
the buffer containing the #GOutputVectors to write.
§cancellable
a #GCancellable, or None
§Returns
%@G_POLLABLE_RETURN_OK on success, PollableReturn::WouldBlock
if the stream is not currently writable (and @error is not set), or
PollableReturn::Failed
if there was an error in which case @error will
be set.
§bytes_written
location to store the number of bytes that were written to the stream
fn into_async_write(self) -> Result<OutputStreamAsyncWrite<Self>, Self>where
Self: IsA<PollableOutputStream>,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.