How to spawn a Tokio task for an associated function that must populate the struct its working on

I am trying to create a programming construct.
the construct serially does run. (it throws some warnings that can be ignored)
This is how it looks like: Rust Playground

Where essentially I instantiate and populate a struct like this:
let mut mystruct = MyStruct::in1().await;
and then modify it like this:

In my actual program I perform multiple instantiations on different structs (!).
The work in the instantiation and modification requires more work to be performed, which includes network lookups, so I want each one of instantiations to be performed in their own thread in parallel.

This looks to me like something that I am not the first to think about, but I cannot make it work with tokio::spawn...

Importantant is that the struct is never used with more than one thread at a time, each thread

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.