-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider improving watchdog API using move semantics #98
Comments
This would work well on my HAL crate: https://github.com/gd32v-rust/gd32vf103-hal/blob/68a9d3b594038480504e3b52abea1a48aefaf148/src/wdog.rs This new API could support the following two scenarios:
By now the current API only support the second one. By this new design we support both second one and the first one, and fallback to second one if library designers still uses the second one by now. |
222: Improve watchdog API design using move semantics r=therealprof a=luojia65 This pull request improved watchdog API design. When starting watchdog, we may convert it into another type. We may implement different functions for this type. Or downstream developers can implement `Watchdog` for only an enabled type, to prevent feed to disabled watchdogs or forget to enable before feeding. If we are able to stop this watchdog, it can be converted into the former type. If current design still need a same type after the watchdog is enabled, they may use `Target = Self`. In this way we create a fallback for earlier designs. A simple proof of concept: [here](https://github.com/gd32v-rust/gd32vf103-hal/blob/new-watchdog-design/src/wdog.rs#L155-L169) (L120-L153 for its `Enable` implementation, and there is `Disable` implementation) Related issue: #98 Earlier discussion: #76 (comment) Co-authored-by: luojia65 <me@luojia.cc> Co-authored-by: Luo Jia <account@luojia.cc>
Yes, I think so. |
@astro suggested the following:
I think this is an interesting approach that's worth thinking about.
The text was updated successfully, but these errors were encountered: