3 ms·
There are tons of network protocols where only certain bit patterns are admissible. The algorithm linked here is substantially more useful than just "your entir
by wyager 2y ago
There are tons of network protocols where only certain bit patterns are admissible. The algorithm linked here is substantially more useful than just "your entire type has to be made of u8s"
- Animats 2y agoYou don't know on input if the bit pattern will be valid. If you're going to coerce raw bytes into it, the usual case for network protocols, you have to be prepared for any bit pattern.
- wyager 2y agoThe article also discusses a `TryTransmute` trait which will cover this case. Additionally, you often want to coerce from the constrained in-memory representation to the wire representation.