[][src]Struct libpulse_binding::mainloop::standard::Mainloop

pub struct Mainloop {
    pub _inner: Rc<MainloopInner<MainloopInternal>>,
}

This acts as a safe interface to the internal PA Mainloop.

The mainloop object pointers are further enclosed here in a ref counted wrapper, allowing this outer wrapper to have clean methods for creating event objects, which can cleanly pass a copy of the inner ref counted mainloop object to them. Giving this to events serves two purposes, firstly because they need the API pointer, secondly, it ensures that event objects do not outlive the mainloop object.

Fields

_inner: Rc<MainloopInner<MainloopInternal>>

The ref-counted inner data.

Implementations

impl Mainloop[src]

pub fn new() -> Option<Self>[src]

Allocates a new main loop object.

pub fn prepare(&mut self, timeout: Option<MicroSeconds>) -> Result<(), PAErr>[src]

Prepares for a single iteration of the main loop.

Returns Err on error or exit request.

timeout specifies a maximum timeout for the subsequent poll. None requests blocking behaviour.

Note, should the microseconds timeout value provided be too large to pass to the underlying C API (larger than std::i32::MAX), then the PAErr form of the Code::TooLarge error will be returned (within Result::Err).

pub fn poll(&mut self) -> Result<u32, PAErr>[src]

Executes the previously prepared poll.

pub fn dispatch(&mut self) -> Result<u32, PAErr>[src]

Dispatchs timeout, IO and deferred events from the previously executed poll.

On success returns the number of source dispatched.

pub fn get_retval(&self) -> Retval[src]

Gets the return value as specified with the main loop’s quit routine.

pub fn iterate(&mut self, block: bool) -> IterateResult[src]

Runs a single iteration of the main loop.

This is a convenience function for prepare, poll and dispatch.

If block is true, block for events if none are queued.

Returns an IterateResult variant:

  • On success, returns IterateResult::Success containing the number of sources dispatched in this iteration.
  • If exit was requested, returns IterateResult::Quit containing quit’s retval.
  • On error, returns IterateResult::Err containing error value.

pub fn run(&mut self) -> Result<Retval, (PAErr, Retval)>[src]

Runs unlimited iterations of the main loop object until the main loop’s quit routine is called.

On success, returns Ok containing quit’s return value. On error returns Err containing a tuple of the error value and quit’s return value.

pub fn get_api<'a>(&self) -> &'a MainloopApi[src]

Gets the abstract main loop abstraction layer vtable for this main loop.

No need to free the API as it is owned by the loop and is destroyed when the loop is freed.

Talking to PA directly with C requires fetching this pointer explicitly via this function. This is actually unnecessary through this binding. The pointer is retrieved automatically upon Mainloop creation, stored internally, and automatically obtained from it by functions that need it.

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

Shuts down the main loop with the specified return value.

pub fn wakeup(&mut self)[src]

Interrupts a running poll (for threaded systems).

pub fn set_poll_func(&mut self, poll_cb: (PollFn, *mut c_void))[src]

Changes the poll() implementation.

Trait Implementations

impl Mainloop for Mainloop[src]

type MI = MainloopInner<MainloopInternal>

impl MainloopSignals for Mainloop[src]

Auto Trait Implementations

impl !RefUnwindSafe for Mainloop

impl !Send for Mainloop

impl !Sync for Mainloop

impl Unpin for Mainloop

impl UnwindSafe for Mainloop

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.