// generated by diplomat-tool import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; // Base enumerator definition /** See the [Rust documentation for `JoiningType`](https://docs.rs/icu/latest/icu/properties/props/struct.JoiningType.html) for more information. */ export class JoiningType { #value = undefined; static #values = new Map([ ["NonJoining", 0], ["JoinCausing", 1], ["DualJoining", 2], ["LeftJoining", 3], ["RightJoining", 4], ["Transparent", 5] ]); static getAllEntries() { return JoiningType.#values.entries(); } constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* // instances of this type, otherwise the enums are treated as singletons. if (arguments[1] === diplomatRuntime.internalConstructor ) { this.#value = arguments[2]; return; } return JoiningType.#objectValues[arguments[1]]; } if (value instanceof JoiningType) { return value; } let intVal = JoiningType.#values.get(value); // Nullish check, checks for null or undefined if (intVal == null) { return JoiningType.#objectValues[intVal]; } throw TypeError(value + " is not a JoiningType and does not correspond to any of its enumerator values."); } get value() { return [...JoiningType.#values.keys()][this.#value]; } get ffiValue() { return this.#value; } static #objectValues = [ new JoiningType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), new JoiningType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), new JoiningType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), new JoiningType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), new JoiningType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), new JoiningType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), ]; static NonJoining = JoiningType.#objectValues[0]; static JoinCausing = JoiningType.#objectValues[1]; static DualJoining = JoiningType.#objectValues[2]; static LeftJoining = JoiningType.#objectValues[3]; static RightJoining = JoiningType.#objectValues[4]; static Transparent = JoiningType.#objectValues[5]; toInteger() { const result = wasm.icu4x_JoiningType_to_integer_mv1(this.ffiValue); try { return result; } finally {} } static fromInteger(other) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_JoiningType_from_integer_mv1(diplomatReceive.buffer, other); try { if (!diplomatReceive.resultFlag) { return null; } return new JoiningType(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); } finally { diplomatReceive.free(); } } }