| // generated by diplomat-tool |
| import wasm from "./diplomat-wasm.mjs"; |
| import * as diplomatRuntime from "./diplomat-runtime.mjs"; |
| |
| |
| /** The sign of a FixedDecimal, as shown in formatting. |
| * |
| *See the [Rust documentation for `Sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.Sign.html) for more information. |
| */ |
| |
| |
| export class FixedDecimalSign { |
| |
| #value = undefined; |
| |
| static #values = new Map([ |
| ["None", 0], |
| ["Negative", 1], |
| ["Positive", 2] |
| ]); |
| |
| static getAllEntries() { |
| return FixedDecimalSign.#values.entries(); |
| } |
| |
| #internalConstructor(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 this; |
| } |
| return FixedDecimalSign.#objectValues[arguments[1]]; |
| } |
| |
| if (value instanceof FixedDecimalSign) { |
| return value; |
| } |
| |
| let intVal = FixedDecimalSign.#values.get(value); |
| |
| // Nullish check, checks for null or undefined |
| if (intVal != null) { |
| return FixedDecimalSign.#objectValues[intVal]; |
| } |
| |
| throw TypeError(value + " is not a FixedDecimalSign and does not correspond to any of its enumerator values."); |
| } |
| |
| static fromValue(value) { |
| return new FixedDecimalSign(value); |
| } |
| |
| get value() { |
| return [...FixedDecimalSign.#values.keys()][this.#value]; |
| } |
| |
| get ffiValue() { |
| return this.#value; |
| } |
| static #objectValues = [ |
| new FixedDecimalSign(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), |
| new FixedDecimalSign(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), |
| new FixedDecimalSign(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), |
| ]; |
| |
| static None = FixedDecimalSign.#objectValues[0]; |
| static Negative = FixedDecimalSign.#objectValues[1]; |
| static Positive = FixedDecimalSign.#objectValues[2]; |
| |
| constructor(value) { |
| return this.#internalConstructor(...arguments) |
| } |
| } |