1// generated by diplomat-tool 2import wasm from "./diplomat-wasm.mjs"; 3import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6/** Documents which days of the week are considered to be a part of the weekend 7* 8*See the [Rust documentation for `weekend`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#method.weekend) for more information. 9*/ 10 11 12export class WeekendContainsDay { 13 14 #monday; 15 16 get monday() { 17 return this.#monday; 18 } 19 set monday(value) { 20 this.#monday = value; 21 } 22 23 #tuesday; 24 25 get tuesday() { 26 return this.#tuesday; 27 } 28 set tuesday(value) { 29 this.#tuesday = value; 30 } 31 32 #wednesday; 33 34 get wednesday() { 35 return this.#wednesday; 36 } 37 set wednesday(value) { 38 this.#wednesday = value; 39 } 40 41 #thursday; 42 43 get thursday() { 44 return this.#thursday; 45 } 46 set thursday(value) { 47 this.#thursday = value; 48 } 49 50 #friday; 51 52 get friday() { 53 return this.#friday; 54 } 55 set friday(value) { 56 this.#friday = value; 57 } 58 59 #saturday; 60 61 get saturday() { 62 return this.#saturday; 63 } 64 set saturday(value) { 65 this.#saturday = value; 66 } 67 68 #sunday; 69 70 get sunday() { 71 return this.#sunday; 72 } 73 set sunday(value) { 74 this.#sunday = value; 75 } 76 77 /** Create `WeekendContainsDay` from an object that contains all of `WeekendContainsDay`s fields. 78 * Optional fields do not need to be included in the provided object. 79 */ 80 static fromFields(structObj) { 81 return new WeekendContainsDay(structObj); 82 } 83 84 #internalConstructor(structObj) { 85 if (typeof structObj !== "object") { 86 throw new Error("WeekendContainsDay's constructor takes an object of WeekendContainsDay's fields."); 87 } 88 89 if ("monday" in structObj) { 90 this.#monday = structObj.monday; 91 } else { 92 throw new Error("Missing required field monday."); 93 } 94 95 if ("tuesday" in structObj) { 96 this.#tuesday = structObj.tuesday; 97 } else { 98 throw new Error("Missing required field tuesday."); 99 } 100 101 if ("wednesday" in structObj) { 102 this.#wednesday = structObj.wednesday; 103 } else { 104 throw new Error("Missing required field wednesday."); 105 } 106 107 if ("thursday" in structObj) { 108 this.#thursday = structObj.thursday; 109 } else { 110 throw new Error("Missing required field thursday."); 111 } 112 113 if ("friday" in structObj) { 114 this.#friday = structObj.friday; 115 } else { 116 throw new Error("Missing required field friday."); 117 } 118 119 if ("saturday" in structObj) { 120 this.#saturday = structObj.saturday; 121 } else { 122 throw new Error("Missing required field saturday."); 123 } 124 125 if ("sunday" in structObj) { 126 this.#sunday = structObj.sunday; 127 } else { 128 throw new Error("Missing required field sunday."); 129 } 130 131 return this; 132 } 133 134 // Return this struct in FFI function friendly format. 135 // Returns an array that can be expanded with spread syntax (...) 136 137 _intoFFI( 138 functionCleanupArena, 139 appendArrayMap 140 ) { 141 return [this.#monday, this.#tuesday, this.#wednesday, this.#thursday, this.#friday, this.#saturday, this.#sunday] 142 } 143 144 static _fromSuppliedValue(internalConstructor, obj) { 145 if (internalConstructor !== diplomatRuntime.internalConstructor) { 146 throw new Error("_fromSuppliedValue cannot be called externally."); 147 } 148 149 if (obj instanceof WeekendContainsDay) { 150 return obj; 151 } 152 153 return WeekendContainsDay.fromFields(obj); 154 } 155 156 _writeToArrayBuffer( 157 arrayBuffer, 158 offset, 159 functionCleanupArena, 160 appendArrayMap 161 ) { 162 diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#monday, Uint8Array); 163 diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 1, this.#tuesday, Uint8Array); 164 diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 2, this.#wednesday, Uint8Array); 165 diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 3, this.#thursday, Uint8Array); 166 diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#friday, Uint8Array); 167 diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 5, this.#saturday, Uint8Array); 168 diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 6, this.#sunday, Uint8Array); 169 } 170 171 // This struct contains borrowed fields, so this takes in a list of 172 // "edges" corresponding to where each lifetime's data may have been borrowed from 173 // and passes it down to individual fields containing the borrow. 174 // This method does not attempt to handle any dependencies between lifetimes, the caller 175 // should handle this when constructing edge arrays. 176 static _fromFFI(internalConstructor, ptr) { 177 if (internalConstructor !== diplomatRuntime.internalConstructor) { 178 throw new Error("WeekendContainsDay._fromFFI is not meant to be called externally. Please use the default constructor."); 179 } 180 let structObj = {}; 181 const mondayDeref = (new Uint8Array(wasm.memory.buffer, ptr, 1))[0] === 1; 182 structObj.monday = mondayDeref; 183 const tuesdayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 1, 1))[0] === 1; 184 structObj.tuesday = tuesdayDeref; 185 const wednesdayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 2, 1))[0] === 1; 186 structObj.wednesday = wednesdayDeref; 187 const thursdayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 3, 1))[0] === 1; 188 structObj.thursday = thursdayDeref; 189 const fridayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 4, 1))[0] === 1; 190 structObj.friday = fridayDeref; 191 const saturdayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 5, 1))[0] === 1; 192 structObj.saturday = saturdayDeref; 193 const sundayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 6, 1))[0] === 1; 194 structObj.sunday = sundayDeref; 195 196 return new WeekendContainsDay(structObj); 197 } 198 199 constructor(structObj) { 200 return this.#internalConstructor(...arguments) 201 } 202}