glib mainloop integration?
I use a zbus ObjectServer inside an application based on Glib's mainloop. Up to zbus 2.0.0-beta.3 I could just plug the file descriptor of zbus::Connection into glib with
pub fn source_add_connection_local<F: FnMut(&zbus::Message) + 'static>(
connection: zbus::Connection,
mut on_message: F,
) -> SourceId {
let fd = connection.as_raw_fd();
glib::source::unix_fd_add_local(
fd,
glib::IOCondition::IN | glib::IOCondition::PRI,
move |_, condition| {
debug!("Connection {file_descriptor} entered IO condition {:?}");
match connection.receive_message() {
Ok(message) => on_message(&message),
Err(err) => error!(
log,
"Failed to process message on connection {}: {:#}", fd, err,
),
}
glib::Continue(true)
},
)
}
In the on_message
callback I'd simply dispatch the message to the object server.
As of zbus-2.0.0-beta.4 this no longer works; for some reason the file descriptor never even enters the IN condition. In other words I never see the debug!
log from above. I tried to make sense of the diff between beta.3 and beta.4, but it looks as if beta.4 migrated to async connections and I'm somewhat unfamiliar with async Rust.
Am I missing something obvious? What's the recommended way to integrate a zbus object server into an external event loop?