// generated by diplomat-tool import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; // Base enumerator definition /** Mode used in a rounding operation. * *See the [Rust documentation for `RoundingMode`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.RoundingMode.html) for more information. */ export class FixedDecimalRoundingMode { #value = undefined; static #values = new Map([ ["Ceil", 0], ["Expand", 1], ["Floor", 2], ["Trunc", 3], ["HalfCeil", 4], ["HalfExpand", 5], ["HalfFloor", 6], ["HalfTrunc", 7], ["HalfEven", 8] ]); static getAllEntries() { return FixedDecimalRoundingMode.#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 FixedDecimalRoundingMode.#objectValues[arguments[1]]; } if (value instanceof FixedDecimalRoundingMode) { return value; } let intVal = FixedDecimalRoundingMode.#values.get(value); // Nullish check, checks for null or undefined if (intVal == null) { return FixedDecimalRoundingMode.#objectValues[intVal]; } throw TypeError(value + " is not a FixedDecimalRoundingMode and does not correspond to any of its enumerator values."); } get value() { return [...FixedDecimalRoundingMode.#values.keys()][this.#value]; } get ffiValue() { return this.#value; } static #objectValues = [ new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6), new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7), new FixedDecimalRoundingMode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8), ]; static Ceil = FixedDecimalRoundingMode.#objectValues[0]; static Expand = FixedDecimalRoundingMode.#objectValues[1]; static Floor = FixedDecimalRoundingMode.#objectValues[2]; static Trunc = FixedDecimalRoundingMode.#objectValues[3]; static HalfCeil = FixedDecimalRoundingMode.#objectValues[4]; static HalfExpand = FixedDecimalRoundingMode.#objectValues[5]; static HalfFloor = FixedDecimalRoundingMode.#objectValues[6]; static HalfTrunc = FixedDecimalRoundingMode.#objectValues[7]; static HalfEven = FixedDecimalRoundingMode.#objectValues[8]; }