dbrgn / espresso

AT based driver crate for ESP8266 WiFi modules.
Apache License 2.0
9 stars 4 forks source link

Proposal: Use types to encode legal states and transitions #5

Open stephanh opened 4 years ago

stephanh commented 4 years ago

I think it would be good to use types to encode state specific methods and transitions between state similar to how embedded_hal does it and guard users from illegal state transitions.

What do you think?

dbrgn commented 4 years ago

Hi. Yep, I did plan to make the API more safe against misuse in the future :slightly_smiling_face: Using typestates would be a nice approach, thanks for the proposal.

I do have one caveat though, I would first want to implement the embedded-nal traits since that might influence the design of the client. For that, the current blocker is receiving incoming data from the ESP device. This in turn is blocked by https://github.com/BlackbirdHQ/atat/issues/33. I already have an idea how it might be possible to handle that though. If time permits, I'll try out that approach in a branch tonight.

stephanh commented 4 years ago

Ok.