Once #5381 merges, we'll have a helper type HexPrimitive in primitives that provides default implementations of FromStr, UpperHex, LowerHex and Display for consensus encodable primitive types. This helper currently requires alloc for both encoding and decoding, which limits its use for no-alloc types like Header.
This issue involves reworking the encoding and decoding logic in HexPrimitive to remove the alloc requirement entirely.
As an extension, types like Header can have the alloc feature gate removed on the UpperHex and LowerHex implementations once the first step is complete.