4 ms·
It's OK but not great. Ideally library authors should provide a sync facade so people don't have to deal with this, like reqwest does.
by rklaehn 3y ago
It's OK but not great.
Ideally library authors should provide a sync facade so people don't have to deal with this, like reqwest does.
- vacuity 3y agoIdeal for library users but not for library authors...
- masklinn 3y agoThe implementation is really not complicated, though it’s hardly great if you expect it to be performant: reqwest just creates a tokio runtime, schedules the task on it, waits for completion, then tears it down. It’s repetitive but it’s simple.
- yencabulator 3y agoWhere it really breaks down is that there's no spawn without tying the library to e.g. tokio. Also, the other way around might be simpler. If the library wants to be async, make it async-only, and let callers block_on it. https://docs.rs/tokio/latest/tokio/runtime/struct.Runtime.html#method.block_on https://docs.rs/tokio/latest/tokio/runtime/struct.Runtime.ht...