I researched a little bit and there seems to be at least 2 ways.
Use num_derive and num_traits.
How do I match enum values with an integer?
has a discussion on this.
Both approaches leverage very popular crates. I wonder which way is preferred? What are the differences between those 2 approaches?