i am building a client application that performs some networking against a server. i'm at the beginning of building it, so all i want to do at the moment is fetch results and display them. i am trying to do so with
await to learn asynchronous rust.
the problem i'm running into is that
Future that has
'static lifetime. however, i want to update state on
self. i guess one way to do this is to use a channel and send messages back to the main thread that owns
self. however, i'd like to learn how i would do this using the correct rust primitives. i have tried to use
Mutex<Rc<Cell<T>>> but i still get the same lifetime error.
how can i get the async block to have a reference that lives beyond the scope of the function? i tried
async move but that doesn't seem to do what i want either.
i have written this playground that demonstrates my issue: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=803d0847c86948931dea7bd7410ebba8
note: i guess i don't need
Mutex since i'm using
spawn_local, but, even if i remove
Mutex, i get the same error.