embedded-hal icon indicating copy to clipboard operation
embedded-hal copied to clipboard

Add `timeout_{us, ms}` to `embedded_hal_async::DelayUs`

Open datdenkikniet opened this issue 2 years ago • 1 comments
trafficstars

Use cases where one wishes to select between a DelayUs::delay_us and a different Future are likely to be quite common.

I propose that we add something like async fn timeout_{us, ms}<F: Future>(timeout: u32, f: F) -> Result<F::Output, TimeoutError> to the DelayUs trait, with a default impl that falls back to a futures::select between self.timeout_{us, ms}() and f.

datdenkikniet avatar Apr 23 '23 11:04 datdenkikniet