Struct Mainloop

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

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§

Source§

impl Mainloop

Source

pub fn new(context: Option<&mut MainContext>) -> Option<Self>

Creates a new GLIB main loop object for the specified GLIB main loop context.

Takes an argument context for the glib::MainContext to use. If context is None the default context is used.

This returns the object in an Rc wrapper, allowing multiple references to be held, which allows event objects to hold one, thus ensuring they do not outlive it.

Source

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

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.

Trait Implementations§

Source§

impl Mainloop for Mainloop

Source§

type MI = MainloopInner<MainloopInternal>

Inner mainloop type.
Source§

fn inner(&self) -> Rc<MainloopInner<MainloopInternal>>

Get inner mainloop.
Source§

fn new_io_event( &mut self, fd: i32, events: FlagSet, callback: Box<dyn FnMut(IoEventRef<Self::MI>, i32, FlagSet)>, ) -> Option<IoEvent<Self::MI>>

Creates a new IO event. Read more
Source§

fn new_timer_event( &mut self, tv: &UnixTs, callback: Box<dyn FnMut(TimeEventRef<Self::MI>)>, ) -> Option<TimeEvent<Self::MI>>

Creates a new timer event. Read more
Source§

fn new_timer_event_rt( &mut self, t: MonotonicTs, callback: Box<dyn FnMut(TimeEventRef<Self::MI>)>, ) -> Option<TimeEvent<Self::MI>>

Creates a new monotonic-based timer event. Read more
Source§

fn new_deferred_event( &mut self, callback: Box<dyn FnMut(DeferEventRef<Self::MI>)>, ) -> Option<DeferEvent<Self::MI>>

Creates a new deferred event. Read more
Source§

fn once_event(&mut self, callback: Box<dyn FnMut()>)

Runs the specified callback once from the main loop using an anonymous defer event. Read more
Source§

fn quit(&mut self, retval: Retval)

Calls quit
Source§

impl MainloopSignals for Mainloop

Source§

fn init_signals(&mut self) -> Result<(), PAErr>

Initializes the UNIX signal subsystem and bind it to the specified main loop.
Source§

fn signals_done(&self)

Cleans up the signal subsystem.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.