enum
Enumeration Type with Named Constants
Functions
| Function | Description |
|---|---|
_enum_byte_at | Internal byte reader. |
_enum_streq | Internal: compare two strings. |
_enum_copy | Internal: copy bytes. |
enum_new | Create a new enum type. name/nlen is the enum’s name (for display). Layout: [… |
enum_add | Add a variant to the enum. Returns index on success, -1 if full. |
enum_by_name | Lookup value by variant name. Returns value or -1 if not found. |
enum_by_val | Lookup name by value. Writes name to out, returns length. -1 if not found. |
enum_count | Return number of variants. |
enum_has | Check if a variant name exists. Returns 1 or 0. |
enum_name_at | Get variant name at index. Returns length written, -1 if out of bounds. |
enum_val_at | Get variant value at index. Returns -1 if out of bounds. |
Details
_enum_byte_at
fn _enum_byte_at(buf: &i8, idx: i64) -> i64Internal byte reader.
_enum_streq
fn _enum_streq(a: &i8, alen: i64, b: &i8, blen: i64) -> i64Internal: 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) -> &i64Create 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) -> i64Add 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) -> i64Lookup value by variant name. Returns value or -1 if not found.
enum_by_val
fn enum_by_val(e: &i64, val: i64, out: &i8) -> i64Lookup name by value. Writes name to out, returns length. -1 if not found.
enum_count
fn enum_count(e: &i64) -> i64Return number of variants.
enum_has
fn enum_has(e: &i64, name: &i8, nlen: i64) -> i64Check if a variant name exists. Returns 1 or 0.
enum_name_at
fn enum_name_at(e: &i64, idx: i64, out: &i8) -> i64Get variant name at index. Returns length written, -1 if out of bounds.
enum_val_at
fn enum_val_at(e: &i64, idx: i64) -> i64Get variant value at index. Returns -1 if out of bounds.