1// generated by diplomat-tool 2import { TimeZoneAndCanonical } from "./TimeZoneAndCanonical.mjs" 3import wasm from "./diplomat-wasm.mjs"; 4import * as diplomatRuntime from "./diplomat-runtime.mjs"; 5 6 7/** See the [Rust documentation for `TimeZoneAndCanonicalIter`](https://docs.rs/icu/latest/icu/time/zone/iana/struct.TimeZoneAndCanonicalIter.html) for more information. 8*/ 9const TimeZoneAndCanonicalIterator_box_destroy_registry = new FinalizationRegistry((ptr) => { 10 wasm.icu4x_TimeZoneAndCanonicalIterator_destroy_mv1(ptr); 11}); 12 13export class TimeZoneAndCanonicalIterator { 14 15 // Internal ptr reference: 16 #ptr = null; 17 18 // Lifetimes are only to keep dependencies alive. 19 // Since JS won't garbage collect until there are no incoming edges. 20 #selfEdge = []; 21 #aEdge = []; 22 23 #internalConstructor(symbol, ptr, selfEdge, aEdge) { 24 if (symbol !== diplomatRuntime.internalConstructor) { 25 console.error("TimeZoneAndCanonicalIterator is an Opaque type. You cannot call its constructor."); 26 return; 27 } 28 29 30 this.#aEdge = aEdge; 31 32 this.#ptr = ptr; 33 this.#selfEdge = selfEdge; 34 35 // Are we being borrowed? If not, we can register. 36 if (this.#selfEdge.length === 0) { 37 TimeZoneAndCanonicalIterator_box_destroy_registry.register(this, this.#ptr); 38 } 39 40 return this; 41 } 42 get ffiValue() { 43 return this.#ptr; 44 } 45 46 #iteratorNext() { 47 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true); 48 49 // This lifetime edge depends on lifetimes 'a 50 let aEdges = [this]; 51 52 const result = wasm.icu4x_TimeZoneAndCanonicalIterator_next_mv1(diplomatReceive.buffer, this.ffiValue); 53 54 try { 55 if (!diplomatReceive.resultFlag) { 56 return null; 57 } 58 return TimeZoneAndCanonical._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer, aEdges); 59 } 60 61 finally { 62 diplomatReceive.free(); 63 } 64 } 65 66 next() { 67 const out = this.#iteratorNext(); 68 69 return { 70 value: out, 71 done: out === null, 72 }; 73 } 74 75 constructor(symbol, ptr, selfEdge, aEdge) { 76 return this.#internalConstructor(...arguments) 77 } 78}