Source code
Revision control
Copy as Markdown
Other Tools
// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";
/**
* See the [Rust documentation for `IsoWeekOfYear`](https://docs.rs/icu/2.1.1/icu/calendar/types/struct.IsoWeekOfYear.html) for more information.
*/
export class IsoWeekOfYear {
#weekNumber;
get weekNumber() {
return this.#weekNumber;
}
set weekNumber(value){
this.#weekNumber = value;
}
#isoYear;
get isoYear() {
return this.#isoYear;
}
set isoYear(value){
this.#isoYear = value;
}
/** @internal */
static fromFields(structObj) {
return new IsoWeekOfYear(structObj);
}
#internalConstructor(structObj) {
if (typeof structObj !== "object") {
throw new Error("IsoWeekOfYear's constructor takes an object of IsoWeekOfYear's fields.");
}
if ("weekNumber" in structObj) {
this.#weekNumber = structObj.weekNumber;
} else {
throw new Error("Missing required field weekNumber.");
}
if ("isoYear" in structObj) {
this.#isoYear = structObj.isoYear;
} else {
throw new Error("Missing required field isoYear.");
}
return this;
}
// Return this struct in FFI function friendly format.
// Returns an array that can be expanded with spread syntax (...)
_intoFFI(
functionCleanupArena,
appendArrayMap
) {
let buffer = diplomatRuntime.DiplomatBuf.struct(wasm, 8, 4);
this._writeToArrayBuffer(wasm.memory.buffer, buffer.ptr, functionCleanupArena, appendArrayMap);
functionCleanupArena.alloc(buffer);
return buffer.ptr;
}
static _fromSuppliedValue(internalConstructor, obj) {
if (internalConstructor !== diplomatRuntime.internalConstructor) {
throw new Error("_fromSuppliedValue cannot be called externally.");
}
if (obj instanceof IsoWeekOfYear) {
return obj;
}
return IsoWeekOfYear.fromFields(obj);
}
_writeToArrayBuffer(
arrayBuffer,
offset,
functionCleanupArena,
appendArrayMap
) {
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#weekNumber, Uint8Array);
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#isoYear, Int32Array);
}
// This struct contains borrowed fields, so this takes in a list of
// "edges" corresponding to where each lifetime's data may have been borrowed from
// and passes it down to individual fields containing the borrow.
// This method does not attempt to handle any dependencies between lifetimes, the caller
// should handle this when constructing edge arrays.
static _fromFFI(internalConstructor, ptr) {
if (internalConstructor !== diplomatRuntime.internalConstructor) {
throw new Error("IsoWeekOfYear._fromFFI is not meant to be called externally. Please use the default constructor.");
}
let structObj = {};
const weekNumberDeref = (new Uint8Array(wasm.memory.buffer, ptr, 1))[0];
structObj.weekNumber = weekNumberDeref;
const isoYearDeref = (new Int32Array(wasm.memory.buffer, ptr + 4, 1))[0];
structObj.isoYear = isoYearDeref;
return new IsoWeekOfYear(structObj);
}
constructor(structObj) {
return this.#internalConstructor(...arguments)
}
}