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 glib::Source 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 PollableInputStreamExt::is_readable(), it is possible that the stream may not actually be readable even after the source triggers, so you should use PollableInputStreamExtManual::read_nonblocking() rather than InputStreamExtManual::read() from the callback.

The behaviour of this method is undefined if PollableInputStreamExt::can_poll() returns false for self.

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 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 InputStreamExtManual::read(). If self is not currently readable, this will immediately return IOErrorEnum::WouldBlock, and you can use PollableInputStreamExtManual::create_source() to create a glib::Source 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 PollableInputStreamExt::can_poll() returns false for self.

cancellable

a Cancellable, 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§