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