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

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

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

Associated Types

Loading content...

Required methods

pub fn inner(&self) -> Rc<Self::MI>[src]

Loading content...

Provided methods

pub fn new_io_event(
    &mut self,
    fd: i32,
    events: IoEventFlagSet,
    callback: Box<dyn FnMut(IoEventRef<Self::MI>, i32, IoEventFlagSet) + 'static>
) -> Option<IoEvent<Self::MI>>
[src]

Creates 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.

pub fn new_timer_event(
    &mut self,
    tv: &UnixTs,
    callback: Box<dyn FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
[src]

Creates 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!"); }));

pub fn new_timer_event_rt(
    &mut self,
    t: MonotonicTs,
    callback: Box<dyn FnMut(TimeEventRef<Self::MI>) + 'static>
) -> Option<TimeEvent<Self::MI>>
[src]

Creates 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!"); }));

pub fn new_deferred_event(
    &mut self,
    callback: Box<dyn FnMut(DeferEventRef<Self::MI>) + 'static>
) -> Option<DeferEvent<Self::MI>>
[src]

Creates 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.

pub fn once_event(&mut self, callback: Box<dyn FnMut() + 'static>)[src]

Runs 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.

pub fn quit(&mut self, retval: Retval)[src]

Calls quit

Loading content...

Implementors

impl Mainloop for libpulse_binding::mainloop::standard::Mainloop[src]

impl Mainloop for libpulse_binding::mainloop::threaded::Mainloop[src]

Loading content...