I don't really understand the lifetime problem above, but I wondered if it's a similar issue like this one that came up in another thread:
But I might be totally wrong.
I tried to use Box::leak
to figure out if I can get the code to compile at least (it would not work, but that might help to find out what's the issue), but unfortunately, I cannot clone the tx
or create a new one from within the non-async closure easily.
Hmmm, I see.
What I mean is, I believe that the type Pin<Box<dyn Future<Output = Result<i64, String>> + Send>>
, which I used in my example, doesn't work because dyn
without lifetime means dyn + 'static
, I think. But the pinned boxed dyn Future
has a lifetime that depends on the transaction and the string slice, and I don't know how to express that.