Numeric ID (0-127) identifying which variant is active
RelishValue for the active variant
RelishEnum value
import { Enum, String_, U32, encode } from '@grounds/core';
// Success variant with message
const success = Enum(0, String_('operation completed'));
encode(success).match(
(bytes) => console.log('Success encoded:', bytes),
(error) => console.error(error)
);
// Error variant with code
const error_ = Enum(1, U32(404));
encode(error_).match(
(bytes) => console.log('Error encoded:', bytes),
(error) => console.error(error)
);
Struct for heterogeneous fixed fields
Creates an enum Relish value (tagged union).
Enums represent one of several variants, each with a numeric ID (0-127) and an associated value. The variant ID and value are encoded together.