The first Problem is sized, which is not an allowed requirement for a trait object. If removing the trait bound of Sized, the constructor does not work anymore.
The second, the functions header_name and parse_header have no receiver.
This resulted in the idea of splitting the trait into two, one requering send, the other not.
How can I achieve a heterognous storage of items based on common traits and the elements having static functions (is there a better way to name them?).
It's completely idiomatic, when appropriate. If you know the complete set of header types you'll have (i.e. it's not something users of your library will come up with), then an enum is usually easier and more flexible to work with.
Each of those headers blocks contain a few more fields plus each of those header fields has a determined encode and parse implementation. If use an enum, I end up using a struct with an enum which ends up being unergonomic.
Hmm, I'm failing to see the lack of ergonomics from your (admittedly brief) description. Could you show something a bit concrete?
But back to your traits, you won't be able to turn them into trait objects, as you've already discovered, as they stand. So if that's the kind of API you'd like to have, more or less, you're going to likely create a lot more unergonomic code than going with an enum . The enum also has a much higher chance of getting more optimal code generated for it than trait objects, which might be a nice side-effect.
I had another idea with a builder pattern incoroporated, but if that fails too I am going to go for Enums. Thanks for the (brief) discussion, much appreciated!