// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";



/**
 * Additional information: [1](https://docs.rs/icu_provider/2.2.0/icu_provider/struct.DataError.html), [2](https://docs.rs/icu_provider/2.2.0/icu_provider/enum.DataErrorKind.html)
 */
export class DataError {
    #value = undefined;

    static #values = new Map([
        ["Unknown", 0],
        ["MarkerNotFound", 1],
        ["IdentifierNotFound", 2],
        ["InvalidRequest", 3],
        ["InconsistentData", 4],
        ["Downcast", 5],
        ["Deserialize", 6],
        ["Custom", 7],
        ["Io", 8]
    ]);

    static getAllEntries() {
        return DataError.#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 DataError.#objectValues[arguments[1]];
        }

        if (value instanceof DataError) {
            return value;
        }

        let intVal = DataError.#values.get(value);

        // Nullish check, checks for null or undefined
        if (intVal != null) {
            return DataError.#objectValues[intVal];
        }

        throw TypeError(value + " is not a DataError and does not correspond to any of its enumerator values.");
    }

    /** @internal */
    static fromValue(value) {
        return new DataError(value);
    }

    get value(){
        return [...DataError.#values.keys()][this.#value];
    }

    /** @internal */
    get ffiValue(){
        return this.#value;
    }
    static #objectValues = [
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6),
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7),
        new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8),
    ];

    static Unknown = DataError.#objectValues[0];
    static MarkerNotFound = DataError.#objectValues[1];
    static IdentifierNotFound = DataError.#objectValues[2];
    static InvalidRequest = DataError.#objectValues[3];
    static InconsistentData = DataError.#objectValues[4];
    static Downcast = DataError.#objectValues[5];
    static Deserialize = DataError.#objectValues[6];
    static Custom = DataError.#objectValues[7];
    static Io = DataError.#objectValues[8];


    constructor(value) {
        return this.#internalConstructor(...arguments)
    }
}