What I'm trying to do is a little bit weird. Initially I used a struct:
struct A {
entity: String,
entity_id_type: String,
entity_id_source: String,
}
I wanted to make sure, that it's not possible to create wrong combinations of these three values, so I changed it to an enum hierarchy:
enum Entity {
EntityA(EntityAIdType)
}
enum EntityAIdType {
TypeA(TypeASource)
}
enum TypeASource {
SourceX,
SourceY,
SourceZ
}
Later on I need to write a lot of Entities into a file and it is a user preference which of the three fields (as seen in the struct) can be printed to the file.
Is it possible to achieve something like this without a massive match
for all possible combinations? I would be fine with output as a list or hash map and can filter it while writing to a file. I would love to have enums to not allow wrong state in the application.
Any ideas?