Rfc9557ParseError.mjs (2782B)
1 // generated by diplomat-tool 2 import wasm from "./diplomat-wasm.mjs"; 3 import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6 /** 7 * Additional information: [1](https://docs.rs/icu/latest/icu/calendar/enum.ParseError.html), [2](https://docs.rs/icu/latest/icu/time/enum.ParseError.html) 8 */ 9 10 11 export class Rfc9557ParseError { 12 #value = undefined; 13 14 static #values = new Map([ 15 ["Unknown", 0], 16 ["InvalidSyntax", 1], 17 ["OutOfRange", 2], 18 ["MissingFields", 3], 19 ["UnknownCalendar", 4] 20 ]); 21 22 static getAllEntries() { 23 return Rfc9557ParseError.#values.entries(); 24 } 25 26 #internalConstructor(value) { 27 if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { 28 // We pass in two internalConstructor arguments to create *new* 29 // instances of this type, otherwise the enums are treated as singletons. 30 if (arguments[1] === diplomatRuntime.internalConstructor ) { 31 this.#value = arguments[2]; 32 return this; 33 } 34 return Rfc9557ParseError.#objectValues[arguments[1]]; 35 } 36 37 if (value instanceof Rfc9557ParseError) { 38 return value; 39 } 40 41 let intVal = Rfc9557ParseError.#values.get(value); 42 43 // Nullish check, checks for null or undefined 44 if (intVal != null) { 45 return Rfc9557ParseError.#objectValues[intVal]; 46 } 47 48 throw TypeError(value + " is not a Rfc9557ParseError and does not correspond to any of its enumerator values."); 49 } 50 51 static fromValue(value) { 52 return new Rfc9557ParseError(value); 53 } 54 55 get value(){ 56 return [...Rfc9557ParseError.#values.keys()][this.#value]; 57 } 58 59 get ffiValue(){ 60 return this.#value; 61 } 62 static #objectValues = [ 63 new Rfc9557ParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), 64 new Rfc9557ParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), 65 new Rfc9557ParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), 66 new Rfc9557ParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), 67 new Rfc9557ParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), 68 ]; 69 70 static Unknown = Rfc9557ParseError.#objectValues[0]; 71 static InvalidSyntax = Rfc9557ParseError.#objectValues[1]; 72 static OutOfRange = Rfc9557ParseError.#objectValues[2]; 73 static MissingFields = Rfc9557ParseError.#objectValues[3]; 74 static UnknownCalendar = Rfc9557ParseError.#objectValues[4]; 75 76 77 constructor(value) { 78 return this.#internalConstructor(...arguments) 79 } 80 }