Skip to main content

js_numeric_enum

Attribute Macro js_numeric_enum 

Source
#[js_numeric_enum]
Expand description

Expose a numeric enum as JavaScript numbers plus a JS constant object.

This is for APIs such as Rong.SeekMode.Start === 0: each unit variant must have an explicit integer value. The generated type accepts numbers from JS, returns numbers to JS, and provides Type::js_object(ctx) for namespace registration.

#[js_numeric_enum]
enum SeekMode {
    Start = 0,
    Current = 1,
    End = 2,
}