Hi - just facing some challenging code and wanted to discuss it to make sure we stay on track.
We’ve got some thread_local variables from the ic-stable-structures crate, currently it’s Cells and BTreeMaps. I wanted to keep the code as neat as possible but then I ran into an issue with the with_borrow() closure and asyncs.
Here’s our register player endpoint so you can see what’s going on. My question is - is there a better way to combine async/non async calls or do they have to be split in this way. If they are separate in the actor it really hurts code maintainability because I can’t combine these logical steps anywhere other than the canister/src/lib.rs file.
So if I wanted a method that checked to see if a game canister could be created, and if so created it, the query part isn’t async so I’d have to do that first… then conditionally create the canister via async.
Basically, all the usual ways of making code neat and tidy go out the window because Rust doesn’t support async closures.
Hope that makes sense!