Trait libpulse_binding::mainloop::api::Mainloop[][src]

pub trait Mainloop {
    type MI: MainloopInnerType;
    fn inner(&self) -> Rc<Self::MI>;

    fn new_io_event(
        &mut self,
        fd: i32,
        events: IoEventFlagSet,
        callback: Box<FnMut(IoEventRef<Self::MI>, i32, IoEventFlagSet) + 'static>
    ) -> Option<IoEvent<Self::MI>> { ... }
fn new_timer_event(
        &mut self,
        tv: &UnixTs,
        callback: Box<FnMut(TimeEventRef<Self::MI>) + 'static>
    ) -> Option<TimeEvent<Self::MI>> { ... }
fn new_timer_event_rt(
        &mut self,
        t: MonotonicTs,
        callback: Box<FnMut(TimeEventRef<Self::MI>) + 'static>
    ) -> Option<TimeEvent<Self::MI>> { ... }
fn new_deferred_event(
        &mut self,
        callback: Box<FnMut(DeferEventRef<Self::MI>) + 'static>
    ) -> Option<DeferEvent<Self::MI>> { ... }
fn once_event(&mut self, callback: Box<FnMut() + 'static>) { ... }
fn quit(&mut self, retval: Retval) { ... } }

Associated Types

Required Methods

Provided Methods

Create a new IO event

Note: You must ensure that the returned event object lives for as long as you want its event(s) to fire, as its Drop implementation destroys the event source. I.e. if you create a new event, but then immediately drop the object returned here, no event will fire!

The given callback must accept three parameters, an IoEventRef object, a copy of the given file descriptor, and an event flag set, indicating the event(s) that occurred. The DeferEventRef object gives you some opportunity to manage the event source from within it's callback execution.

Create a new timer event

Note: You must ensure that the returned event object lives for as long as you want its event(s) to fire, as its Drop implementation destroys the event source. I.e. if you create a new event, but then immediately drop the object returned here, no event will fire!

The callback must take a TimeEventRef object, which gives you some opportunity to manage the event source from within it's callback execution.

Example event set to fire in five seconds time:

This example is not tested
use pulse::time::{UnixTs, MicroSeconds, MICROS_PER_SEC};
let _t_event = mainloop.new_timer_event(
    &(UnixTs::now() + MicroSeconds(5 * MICROS_PER_SEC)),
    Box::new(|| { println!("Timer event fired!"); }));

Create a new monotonic-based timer event

Asserts that t is not USEC_INVALID

This is an alternative to the new_timer_event method, taking a monotonic based time value.

Note: You must ensure that the returned event object lives for as long as you want its event(s) to fire, as its Drop implementation destroys the event source. I.e. if you create a new event, but then immediately drop the object returned here, no event will fire!

The callback must take a TimeEventRef object, which gives you some opportunity to manage the event source from within it's callback execution.

Example event set to fire in five seconds time:

This example is not tested
use pulse::time::{MonotonicTs, MicroSeconds, MICROS_PER_SEC};
let _t_event = mainloop.new_timer_event_rt(
    MonotonicTs::now() + MicroSeconds(5 * MICROS_PER_SEC),
    Box::new(|| { println!("Timer event fired!"); }));

Create a new deferred event

Note: You must ensure that the returned event object lives for as long as you want its event(s) to fire, as its Drop implementation destroys the event source. I.e. if you create a new event, but then immediately drop the object returned here, no event will fire!

The callback must take a DeferEventRef object, which gives you some opportunity to manage the event source from within it's callback execution.

Run the specified callback once from the main loop using an anonymous defer event. If the mainloop runs in a different thread, you need to follow the mainloop implementation's rules regarding how to safely create defer events. In particular, if you're using ::mainloop::threaded, you must lock the mainloop before calling this function.

Call quit

Implementors