implement encoding and decode of structure containing enumeration