enum

Enumeration Type with Named Constants

Functions

FunctionDescription
_enum_byte_atInternal byte reader.
_enum_streqInternal: compare two strings.
_enum_copyInternal: copy bytes.
enum_newCreate a new enum type. name/nlen is the enum’s name (for display). Layout: […
enum_addAdd a variant to the enum. Returns index on success, -1 if full.
enum_by_nameLookup value by variant name. Returns value or -1 if not found.
enum_by_valLookup name by value. Writes name to out, returns length. -1 if not found.
enum_countReturn number of variants.
enum_hasCheck if a variant name exists. Returns 1 or 0.
enum_name_atGet variant name at index. Returns length written, -1 if out of bounds.
enum_val_atGet variant value at index. Returns -1 if out of bounds.

Details

_enum_byte_at

fn _enum_byte_at(buf: &i8, idx: i64) -> i64

Internal byte reader.

_enum_streq

fn _enum_streq(a: &i8, alen: i64, b: &i8, blen: i64) -> i64

Internal: compare two strings.

_enum_copy

fn _enum_copy(dst: &i8, doff: i64, src: &i8, soff: i64, n: i64)

Internal: copy bytes.

enum_new

fn enum_new(name: &i8, nlen: i64) -> &i64

Create a new enum type. name/nlen is the enum’s name (for display). Layout: [0]=count, [1]=cap, [2]=name_buf_ptr, [3]=vals_ptr, [4]=name_offsets_ptr, [5]=name_lens_ptr, [6]=name_buf_used

enum_add

fn enum_add(e: &i64, name: &i8, nlen: i64, val: i64) -> i64

Add a variant to the enum. Returns index on success, -1 if full.

enum_by_name

fn enum_by_name(e: &i64, name: &i8, nlen: i64) -> i64

Lookup value by variant name. Returns value or -1 if not found.

enum_by_val

fn enum_by_val(e: &i64, val: i64, out: &i8) -> i64

Lookup name by value. Writes name to out, returns length. -1 if not found.

enum_count

fn enum_count(e: &i64) -> i64

Return number of variants.

enum_has

fn enum_has(e: &i64, name: &i8, nlen: i64) -> i64

Check if a variant name exists. Returns 1 or 0.

enum_name_at

fn enum_name_at(e: &i64, idx: i64, out: &i8) -> i64

Get variant name at index. Returns length written, -1 if out of bounds.

enum_val_at

fn enum_val_at(e: &i64, idx: i64) -> i64

Get variant value at index. Returns -1 if out of bounds.