The key property of unions is that all fields of a union share common storage. As a result, writes to one field of a union can overwrite its other fields, and size of a union is determined by the size of its largest field.
An alternative solution (more like a workaround) is to use a u32 in the bitfield and decide when you need it what kind of texture dimension you need and decode the u32 to one of the first tree bitfields.
https://doc.rust-lang.org/reference/items/unions.html
An alternative solution (more like a workaround) is to use a u32 in the bitfield and decide when you need it what kind of texture dimension you need and decode the u32 to one of the first tree bitfields.