Randomizing a packed struct which has an enum

I am new to constraints and trying to understand how they work with structs and enums.
I would like to know what is the right way to randomize such that the enum has legal values.
eg a struct like this

typedef enum {STATE_GOOD = 0, STATE_BAD = 2} enum_e;
typedef struct packed {
logic var_a;
enum_e var_b;
}struct_t;

rand struct_t str_s;

If I call std::randomize(str_s), the enum in it can have a non-specified value.
Whereas if I call .randomize() on the object which has that struct, the enum has a legal value.

Does this mean std::randomize treats the packed struct as a bit array?

Thanks

In reply to prang:
Yes, packed structs are treated as a packed array of bits. You will either need to make your struck unpacked, or constrain str_s.var_b to the legal values for that enum.

In reply to dave_59:

Thanks Dave. Does this apply even to structs instantiated in a class?

eg.


class transaction_obj extends ovm_object
  rand struct_t str_s;
`ovm_object_utils(transaction_obj)
  `ovm_field_int(str_s, OVM_ALL_ON)
`ovm_object_utils_end

function new();
..
endclass

class test_seq extends ovm_sequence#(transaction_obj)
  rand transaction_obj trans_a;
...
  task body();
   trans_a = transaction_obj::type_id::create(...);
   trans_a.randomize(); // --> Will the struct in trans_a also be treated as packed array of bits?
  endtask
endclass

I tried this in edaplayground and it always randomized to legal values for enum.