-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
examples: Add example for custom class structs and virtual methods #1378
Conversation
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/tree/main/net/rtp/src/basedepay, https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/tree/main/net/rtp/src/baseaudiopay and https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/tree/main/net/rtp/src/basepay might also be of interest to you then :) |
Nothing, they shouldn't be sealed :) Do we have any left somewhere that are sealed in this situation? If so we should fix that. I thought I did that a while ago already.
The struct should be outside the implementation module (unless it's a final type, etc). It's public API, even if you don't use it from Rust directly (usually). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice example, and much better than https://github.com/sdroege/gobject-example-rs
Now only need to add C API stuff here and we can retire that one
Awesome, thanks! |
304e98b
to
580270e
Compare
26f4219
to
fc5a0b4
Compare
@sdroege Done. Now that the ffi boundary is more clearly defined I took the liberty of moving the class structs into the ffi module. |
fc5a0b4
to
551cb54
Compare
Adds a very detailed example of virtual methods and interfaces. We already had one in gtk4, but not here. I also couldn't find any example for properly chaining up interface vfuncs.
The example is a bit elaborate, but I am convinced that every class here has some merit. It was for example unexpected to me that the interface had to be re-declared in the subclass a second time to override its vfunc, as this is not required for classes. I can however split it up if that is desired.
Some questions that came up:
Ext
traits be sealed? They have a bound that is equal to their implementation, so I'm not entirely sure what that would accomplish.