enum encoding compatible with protobuf