Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some quality-of-life gdbus helpers #1558

Merged
merged 6 commits into from
Nov 2, 2024

Conversation

swsnr
Copy link
Contributor

@swsnr swsnr commented Oct 28, 2024

Add a helper to return a standard result type from an invocation, automatically wrapping the return value into a tuple if it isn't a tuple yet.

Add another helper to return an async result from a future.

Update the gdbus example to demo the new async helper, and show how to simplify parameter handling with auto-derived variant structs.

@swsnr swsnr force-pushed the dbus-invocation-qol branch from a490113 to 4c7e15f Compare October 28, 2024 16:51
@swsnr swsnr force-pushed the dbus-invocation-qol branch from 4c7e15f to 7ebb847 Compare October 31, 2024 06:56
@swsnr swsnr requested a review from bilelmoussaoui October 31, 2024 06:59
@swsnr swsnr force-pushed the dbus-invocation-qol branch from 7ebb847 to 53076df Compare October 31, 2024 07:08
examples/gio_dbus_register_object/main.rs Outdated Show resolved Hide resolved
gio/src/lib.rs Outdated Show resolved Hide resolved
@swsnr swsnr force-pushed the dbus-invocation-qol branch 2 times, most recently from c17799f to 8dc90c6 Compare October 31, 2024 19:58
@swsnr
Copy link
Contributor Author

swsnr commented Oct 31, 2024

Accidentally committed some left over change, I'll fix this tomorrow.

@swsnr swsnr force-pushed the dbus-invocation-qol branch from 8dc90c6 to ee24ad8 Compare November 1, 2024 16:42
@swsnr swsnr force-pushed the dbus-invocation-qol branch 2 times, most recently from 4d89fbe to 149f77c Compare November 1, 2024 17:06
@swsnr
Copy link
Contributor Author

swsnr commented Nov 1, 2024

@sdroege Pipeline passes now, but the question about the name still stands... should I rename the method?

swsnr added 2 commits November 2, 2024 07:13
This trait represents a parsed method call with deserialized arguments,
to abstract over call parsing.

Then add new registration builder helpers to register method calls with
a simplified callback which receives parsed arguments, and can
optionally return an async result.
@swsnr swsnr force-pushed the dbus-invocation-qol branch from 8c9d142 to 7bb83b2 Compare November 2, 2024 06:13
Copy link
Member

@sdroege sdroege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bilelmoussaoui bilelmoussaoui merged commit e654278 into gtk-rs:main Nov 2, 2024
48 checks passed
@bilelmoussaoui bilelmoussaoui added the needs-backport PR needs backporting to the current stable branch label Nov 2, 2024
@swsnr swsnr deleted the dbus-invocation-qol branch November 2, 2024 10:16
@swsnr
Copy link
Contributor Author

swsnr commented Nov 2, 2024

Thank you for reviewing and merging 🙏

glib::timeout_future(Duration::from_secs(delay as u64)).await;
let greet = format!("Hello {name} after {delay} seconds!");
println!("{greet}");
Ok(Some(greet.to_variant()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also figure out a way to make the return value more type safe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type safety as in "the return value matches the signature of the Dbus interface"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Maybe the structs in the enum need to implement a trait with an associated type for that, or so. I think that would all require a bit of reorganization though

@sdroege sdroege removed the needs-backport PR needs backporting to the current stable branch label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants