Skip to content

Commit 7ed7df4

Browse files
tautropflisdroege
authored andcommitted
Split constructors to simplify signature
1 parent 95f0ccb commit 7ed7df4

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

gio/src/dbus_object_manager_client.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,36 @@ impl DBusObjectManagerClient {
128128
flags: DBusObjectManagerClientFlags,
129129
name: &str,
130130
object_path: &str,
131+
) -> Pin<Box<dyn Future<Output = Result<DBusObjectManagerClient, glib::Error>> + 'static>> {
132+
Self::new_future_impl(connection, flags, name, object_path, None)
133+
}
134+
135+
pub fn new_future_with_fn<
136+
F: Fn(&DBusObjectManagerClient, &str, Option<&str>) -> glib::types::Type
137+
+ Send
138+
+ Sync
139+
+ 'static,
140+
>(
141+
connection: &DBusConnection,
142+
flags: DBusObjectManagerClientFlags,
143+
name: &str,
144+
object_path: &str,
145+
get_proxy_type_func: F,
146+
) -> Pin<Box<dyn Future<Output = Result<DBusObjectManagerClient, glib::Error>> + 'static>> {
147+
Self::new_future_impl(
148+
connection,
149+
flags,
150+
name,
151+
object_path,
152+
Some(Box::new(get_proxy_type_func)),
153+
)
154+
}
155+
156+
fn new_future_impl(
157+
connection: &DBusConnection,
158+
flags: DBusObjectManagerClientFlags,
159+
name: &str,
160+
object_path: &str,
131161
get_proxy_type_func: Option<DBusProxyTypeFn>,
132162
) -> Pin<Box<dyn Future<Output = Result<DBusObjectManagerClient, glib::Error>> + 'static>> {
133163
let connection = connection.clone();
@@ -254,6 +284,36 @@ impl DBusObjectManagerClient {
254284
flags: DBusObjectManagerClientFlags,
255285
name: &str,
256286
object_path: &str,
287+
) -> Pin<Box<dyn Future<Output = Result<DBusObjectManagerClient, glib::Error>> + 'static>> {
288+
Self::new_for_bus_future_impl(bus_type, flags, name, object_path, None)
289+
}
290+
291+
pub fn new_for_bus_future_with_fn<
292+
F: Fn(&DBusObjectManagerClient, &str, Option<&str>) -> glib::types::Type
293+
+ Send
294+
+ Sync
295+
+ 'static,
296+
>(
297+
bus_type: BusType,
298+
flags: DBusObjectManagerClientFlags,
299+
name: &str,
300+
object_path: &str,
301+
get_proxy_type_func: F,
302+
) -> Pin<Box<dyn Future<Output = Result<DBusObjectManagerClient, glib::Error>> + 'static>> {
303+
Self::new_for_bus_future_impl(
304+
bus_type,
305+
flags,
306+
name,
307+
object_path,
308+
Some(Box::new(get_proxy_type_func)),
309+
)
310+
}
311+
312+
fn new_for_bus_future_impl(
313+
bus_type: BusType,
314+
flags: DBusObjectManagerClientFlags,
315+
name: &str,
316+
object_path: &str,
257317
get_proxy_type_func: Option<DBusProxyTypeFn>,
258318
) -> Pin<Box<dyn Future<Output = Result<DBusObjectManagerClient, glib::Error>> + 'static>> {
259319
let name = String::from(name);

0 commit comments

Comments
 (0)