Private
Public Access
1
0

fix all warnings

This commit is contained in:
2025-06-16 19:25:24 -07:00
parent 9d591dffc5
commit 75fe4d4608
8 changed files with 18 additions and 110 deletions

View File

@@ -73,57 +73,3 @@ impl DbusRegistry {
self.connection.send(message)
}
}
// Keep the old Endpoint struct for backward compatibility during transition
#[derive(Clone)]
pub struct Endpoint<T: Send + Clone + 'static> {
connection: Arc<SyncConnection>,
implementation: T,
}
impl<T: Send + Clone + 'static> Endpoint<T> {
pub fn new(connection: Arc<SyncConnection>, implementation: T) -> Self {
Self {
connection,
implementation,
}
}
pub async fn register_object<F, R>(&self, path: &str, register_fn: F)
where
F: Fn(&mut Crossroads) -> R,
R: IntoIterator<Item = dbus_crossroads::IfaceToken<T>>,
{
let dbus_path = String::from(path);
// Enable async support for the crossroads instance.
// (Currently irrelevant since dbus generates sync code)
let mut cr = Crossroads::new();
cr.set_async_support(Some((
self.connection.clone(),
Box::new(|x| {
tokio::spawn(x);
}),
)));
// Register the daemon as a D-Bus object with multiple interfaces
let tokens: Vec<_> = register_fn(&mut cr).into_iter().collect();
cr.insert(dbus_path, &tokens, self.implementation.clone());
// Start receiving messages.
self.connection.start_receive(
MatchRule::new_method_call(),
Box::new(move |msg, conn| cr.handle_message(msg, conn).is_ok()),
);
info!(target: "dbus", "Registered endpoint at {} with {} interfaces", path, tokens.len());
}
pub fn send_signal<S>(&self, path: &str, signal: S) -> Result<u32, ()>
where
S: dbus::message::SignalArgs + dbus::arg::AppendAll,
{
let message = signal.to_emit_message(&Path::new(path).unwrap());
self.connection.send(message)
}
}