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

support for async on_transition() and on_dispatch() #28

Open
andrew-otiv opened this issue Oct 21, 2024 · 3 comments
Open

support for async on_transition() and on_dispatch() #28

andrew-otiv opened this issue Oct 21, 2024 · 3 comments

Comments

@andrew-otiv
Copy link

We just tried to make all the methods of our state machine async. For on transition we hit:

  --> bazel-out/k8-fastbuild/bin/otiv3/pipeline_manager_process/state_machines/state_machine.rs:87:21
   |
87 |     on_transition = "Self::on_transition",
   |                     ^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
   |
   = note: expected fn pointer `for<'a, 'b, 'c> fn(&'a mut StateMachineStruct<_>, &'b State, &'c State) -> ()`
                 found fn item `for<'a, 'b, 'c> fn(&'a mut StateMachineStruct<_>, &'b State, &'c State) -> impl Future<Output = ()> {StateMachineStruct::<Handler>::on_transition}`

We get a similar error for on_dispatch. These methods aren't used in your async example. Are they just not supported yet?

Thanks!

@andrew-otiv
Copy link
Author

ON_DISPATCH and ON_TRANSITION in the trait IntoStateMachine are non-async.

Thus, the issue isn't just in the macro.

@andrew-otiv
Copy link
Author

Draft PR: #29

Draft because at the moment we haven't run the test suite yet.

@mdeloof
Copy link
Owner

mdeloof commented Jan 8, 2025

Hi, I've been working on merging the no_std_async branch and there I've made the callback hooks async. on_dispatch and on_transition have been renamed to before_dispatch and after_transition respectively, and two new hooks - after_dispatch and after_transition - have been added.

Feel free to try it out and let me know if you encounter any issues. :)

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