Add From<Duration> conversion for Instant#47
Conversation
|
@daxpedda Any chance we could get this merged? It's a blocker for anyone using server-side WASM runtimes (e.g. |
|
I would be great if you could outline the use-case in the OP. I'm also not really sure what it means, you can't simply convert a The bigger issue here is that this conversion doesn't exist in Std. This library specifically aims to be a drop-in replacement for If you are just trying to create an |
|
Thanks for your feedback. First the use case - WebAssembly is a technology independent of the browser. Thus it is not guaranteed that on execution, WASM modules will have access to the JS API. For any WebAssembly implementation using A real world example - impl quinn::Runtime for SeliumQuinnRuntime {
fn now(&self) -> web_time::Instant {
let i = crate::time::Instant::now().expect("failed to get monotonic time from host");
let d = std::time::Duration::from_nanos(i.as_nanos());
web_time::Instant::from(d)
}
...
}Selium has its own client library (the I take your point about lack of compatibility with the std lib however. I've updated my patch to extend |
This is a pretty innocuous change, but is a necessary escape hatch for using
web_timeon server-side WASM runtimes (e.g. wasmtime).For example: