Is there any way of creating Futures without creating an async function?

I am implementing an actix responder which returns a Future. In my case in the responder however I dont really do any async operations what i do is pretty much just to json serialize Self and return the resulting json string.
Is there a way to create static futures similar to Promise.resolve from javascript ?

future::ready

2 Likes

Or an async block, async move { value }

with an async block I also need to wrap the thing in Box::pin afaik

That certainly depends on what you need it for. The async block is definitely a future, although it might not be Unpin and definitely is not nameable.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.