Trait futures_glib::SourceFuncs [] [src]

pub trait SourceFuncs: Sized {
    type CallbackArg;
    fn prepare(&self, source: &Source<Self>) -> (bool, Option<Duration>);
fn check(&self, source: &Source<Self>) -> bool;
fn dispatch(
        &self,
        source: &Source<Self>,
        f: GSourceFunc,
        data: gpointer
    ) -> bool;
fn g_source_func<F>() -> GSourceFunc
    where
        F: FnMut(Self::CallbackArg) -> bool
; }

Trait for the callbacks that will be invoked by the Source type.

Associated Types

Type passed to the callback in dispatch.

Required Methods

Called before all the file descriptors are polled.

If the source can determine that it is ready here (without waiting for the results of the poll() call) it should return true. It can also return a timeout value which should be the maximum timeout which should be passed to the poll() call.

The actual timeout used will be -1 if all sources returned None or it will be the minimum of all the timeout_ values returned which were >= 0. If prepare returns a timeout and the source also has a 'ready time' set then the nearer of the two will be used.

Called after all the file descriptors are polled.

The source should return true if it is ready to be dispatched. Note that some time may have passed since the previous prepare function was called, so the source should be checked again here.

Called to dispatch the event source, after it has returned true in either its prepare or its check function.

The dispatch function is passed in a callback function. The dispatch function should call the callback function. The return value of the dispatch function should be false if the source should be removed or true to keep it.

Returns an FFI function pointer to invoke the closure specified.

This is used to implement the set_callback function.

Implementors