I want to implement timeouts in my
embedded-hal-based driver. For example, it will send request to uart, then wait for response with timeout.
As I understand,
embedded_hal::timer::CountDown is the main trait for timers. These timers are not reusable: one instance is intended to fire once and then to become unusable:
Otherwise the behavior of calling
waitafter the last call returned
Okis UNSPECIFIED. Implementers are suggested to panic on this scenario to signal a programmer error.
I don't want each query method to take a timer as argument, it's too uncomfortable to use. I want timeout to be configured once when creating driver instance.
What should I do? Make driver instance to have a
FnMut() -> C field (
where C: CountDown)?