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 async
/await
to learn asynchronous rust.
the problem i'm running into is that spawn
/spawn_local
require 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: Rust Playground
note: i guess i don't need Mutex
since i'm using LocalSpawnExt
and spawn_local
, but, even if i remove Mutex
, i get the same error.