Trait gio::prelude::PollableInputStreamExtManual

source ·
pub trait PollableInputStreamExtManual: Sealed + IsA<PollableInputStream> + Sized {
    // 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 read_nonblocking<C: IsA<Cancellable>>(
        &self,
        buffer: &mut [u8],
        cancellable: Option<&C>,
    ) -> Result<isize, Error> { ... }
    fn into_async_read(self) -> Result<InputStreamAsyncRead<Self>, Self>
       where Self: IsA<PollableInputStream> { ... }
}

Provided Methods§

source

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>,

Creates a #GSource that triggers when @self can be read, or @cancellable is triggered or an error occurs. The callback on the source is of the #GPollableSourceFunc type.

As with g_pollable_input_stream_is_readable(), it is possible that the stream may not actually be readable even after the source triggers, so you should use g_pollable_input_stream_read_nonblocking() rather than g_input_stream_read() from the callback.

The behaviour of this method is undefined if g_pollable_input_stream_can_poll() returns false for @self.

§cancellable

a #GCancellable, or None

§Returns

a new #GSource

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 read_nonblocking<C: IsA<Cancellable>>( &self, buffer: &mut [u8], cancellable: Option<&C>, ) -> Result<isize, Error>

Attempts to read up to @count bytes from @self into @buffer, as with g_input_stream_read(). If @self is not currently readable, this will immediately return IOErrorEnum::WouldBlock, and you can use g_pollable_input_stream_create_source() to create a #GSource that will be triggered when @self is readable.

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.

The behaviour of this method is undefined if g_pollable_input_stream_can_poll() returns false for @self.

§cancellable

a #GCancellable, or None

§Returns

the number of bytes read, or -1 on error (including IOErrorEnum::WouldBlock).

§buffer

a buffer to read data into (which should be at least @count bytes long).

source

fn into_async_read(self) -> Result<InputStreamAsyncRead<Self>, Self>
where Self: IsA<PollableInputStream>,

Object Safety§

This trait is not object safe.

Implementors§