Hey everyone,
I’m trying to take a step from intermediate to advanced rust. I’ve figured out how the magic function parameter matching works like in Axum, Tauri, and Bevy which I’m pretty happy with. Now I’m trying to work out how all three deal with state (or resources).
Axum seems to rebox and re type erase your handlers whenever you call with_state. Tauri seems to be by far the simplest, they use TypeMap from the state crate to store variables in the global scope, making it easy to share across threads if you wrap your stuff in a mutex or rwlock.
But what does Bevy do to make their resources work? How about in a multithreaded manner? The codebases are much more spread out than the other two, so I’m having a very hard time finding the relevant bits of code whereas in the other two it was much easier. Does it do something similar to Tauri? I don’t think it’s works like Axum. I’m assuming they do some sort of TypeMap under the hood, possibly one they created whereas Tauri is using the state crate. Does it also keep variables in a global scope?
Sorry for the winding question, I guess im sort of hoping for either a brief explanation or a pointer in the right direction in terms of which bevy codebase I can look in.
Thanks!!