ah- / anne-key

Firmware for Anne Pro Keyboard written in Rust
Apache License 2.0
567 stars 32 forks source link

parse protocol bytes via num-traits #95

Open hdhoang opened 5 years ago

hdhoang commented 5 years ago

Also express the message-ACK relationship better.

todo: propagate further up the stack with better error handling.

implement #92, and may help with #20, #63.

Pzixel commented 5 years ago
Self::from_u8(b).expect("unhandled MsgType")

From the docs:

Simple and safe type conversions in to Self. It is the reciprocal of Into.

Note: this trait must not fail. If the conversion can fail, use TryFrom or a dedicated method which returns an Option or a Result<T, E>.

So From shouldn't fail, and by fail they mean any failure, including panic, I consulted the devs some time ago, so you break the core assumptions by that.

hdhoang commented 5 years ago

great, thanks for the pointer! I will move the error-handling somewhere more appropriate.