Skip to content

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 requested a review from bilelmoussaoui October 31, 2024 06:59
@swsnr
Copy link
Contributor Author

swsnr commented Oct 31, 2024

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

@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.
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