Struct pris::EventManager
source · [−]pub struct EventManager<'a> { /* private fields */ }
Expand description
A struct that simplifies the process of adding
and removing listeners and callbacks to/from MPRIS
DBus
signals.
Implementations
sourceimpl EventManager<'_>
impl EventManager<'_>
sourcepub fn new(conn: &SyncConnection) -> EventManager<'_>
pub fn new(conn: &SyncConnection) -> EventManager<'_>
Creates a new event manager.
sourcepub async fn add_callback<F>(
&mut self,
event_type: EventType,
callback: F
) -> Result<MsgMatch, Box<dyn Error>> where
F: FnMut(Message) -> bool + Send + 'static,
pub async fn add_callback<F>(
&mut self,
event_type: EventType,
callback: F
) -> Result<MsgMatch, Box<dyn Error>> where
F: FnMut(Message) -> bool + Send + 'static,
Adds a new callback to the event manager.
Callbacks can be provided either as a closure, or as
a function. A callback takes only one parameter, a
Message
.
Errors
Returns an Err
if there is a failure in adding
a match rule to the connection.
Example
let mut manager = EventManager::new(&connection);
// Be advised that it is important that this is assigned to a variable
let _incoming = manager
.add_callback(EventType::PropertiesChanged, |msg| {
println!("Data: {:?}", msg);
true
})
.await?;
Auto Trait Implementations
impl<'a> !RefUnwindSafe for EventManager<'a>
impl<'a> Send for EventManager<'a>
impl<'a> Sync for EventManager<'a>
impl<'a> Unpin for EventManager<'a>
impl<'a> !UnwindSafe for EventManager<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more