pub trait PollableOutputStreamExtManual {
    // Required methods
    fn create_source<F, C>(
        &self,
        cancellable: Option<&C>,
        name: Option<&str>,
        priority: Priority,
        func: F
    ) -> Source
       where F: FnMut(&Self) -> Continue + '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>;

    // Provided method
    fn into_async_write(self) -> Result<OutputStreamAsyncWrite<Self>, Self>
       where Self: IsA<PollableOutputStream> { ... }
}

Required Methods§

source

fn create_source<F, C>( &self, cancellable: Option<&C>, name: Option<&str>, priority: Priority, func: F ) -> Sourcewhere F: FnMut(&Self) -> Continue + 'static, C: IsA<Cancellable>,

Creates a glib::Source 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 PollableOutputStreamExt::is_writable(), it is possible that the stream may not actually be writable even after the source triggers, so you should use PollableOutputStreamExt::write_nonblocking() rather than OutputStreamExt::write() from the callback.

cancellable

a Cancellable, or None

Returns

a new glib::Source

source

fn create_source_future<C: IsA<Cancellable>>( &self, cancellable: Option<&C>, priority: Priority ) -> Pin<Box<dyn Future<Output = ()> + 'static>>

source

fn create_source_stream<C: IsA<Cancellable>>( &self, cancellable: Option<&C>, priority: Priority ) -> Pin<Box<dyn Stream<Item = ()> + 'static>>

source

fn writev_nonblocking( &self, vectors: &[OutputVector<'_>], cancellable: Option<&impl IsA<Cancellable>> ) -> Result<(PollableReturn, usize), Error>

Available on crate feature v2_60 only.

Attempts to write the bytes contained in the n_vectors vectors to self, as with OutputStreamExtManual::writev(). If self is not currently writable, this will immediately return %PollableReturn::WouldBlock, and you can use PollableOutputStreamExtManual::create_source() to create a glib::Source 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.

vectors

the buffer containing the GOutputVectors to write.

cancellable

a Cancellable, or None

Returns

%PollableReturn::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

Provided Methods§

Implementors§