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

Using struct methods as callback for subscription #185

Open
OmkarKabadagi5823 opened this issue Mar 11, 2023 · 1 comment
Open

Using struct methods as callback for subscription #185

OmkarKabadagi5823 opened this issue Mar 11, 2023 · 1 comment

Comments

@OmkarKabadagi5823
Copy link

I wanted to know if there is a way to use a struct method as callback similar to how class methods can be used in roscpp and rospy. On a very cursory look at some online threads, it seems rust is not very callback friendly, but I still wanted to know if there is a way to do it.

@adnanademovic
Copy link
Owner

The approach would be the same as any other callbacks in Rust. Just encapsulate the method into a callback.
So MyStruct::something would be called with move || my_struct.something(). If you do not want ownership to be given, you can use Arc.

If I understood the question correctly.

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

No branches or pull requests

2 participants