Trait gio::prelude::PollableInputStreamExtManual[][src]

pub trait PollableInputStreamExtManual: Sized {
    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 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>
, { ... } }

Required methods

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.

cancellable

a Cancellable, or None

Returns

a new glib::Source

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.

buffer

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

cancellable

a Cancellable, or None

Returns

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

Provided methods

Implementors