// generated by diplomat-tool import { LineBreakStrictness } from "./LineBreakStrictness.mjs" import { LineBreakWordOption } from "./LineBreakWordOption.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; /** See the [Rust documentation for `LineBreakOptions`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakOptions.html) for more information. */ export class LineBreakOptions { #strictness; get strictness() { return this.#strictness; } set strictness(value) { this.#strictness = value; } #wordOption; get wordOption() { return this.#wordOption; } set wordOption(value) { this.#wordOption = value; } constructor(structObj) { if (typeof structObj !== "object") { throw new Error("LineBreakOptions's constructor takes an object of LineBreakOptions's fields."); } if ("strictness" in structObj) { this.#strictness = structObj.strictness; } else { this.#strictness = null; } if ("wordOption" in structObj) { this.#wordOption = structObj.wordOption; } else { this.#wordOption = null; } } // Return this struct in FFI function friendly format. // Returns an array that can be expanded with spread syntax (...) _intoFFI( functionCleanupArena, appendArrayMap ) { return [...diplomatRuntime.optionToArgsForCalling(this.#strictness, 4, 4, false, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)]), ...diplomatRuntime.optionToArgsForCalling(this.#wordOption, 4, 4, false, (arrayBuffer, offset, jsValue) => [diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)])] } _writeToArrayBuffer( arrayBuffer, offset, functionCleanupArena, appendArrayMap ) { diplomatRuntime.writeOptionToArrayBuffer(arrayBuffer, offset + 0, this.#strictness, 4, 4, (arrayBuffer, offset, jsValue) => diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array)); diplomatRuntime.writeOptionToArrayBuffer(arrayBuffer, offset + 8, this.#wordOption, 4, 4, (arrayBuffer, offset, jsValue) => diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, 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("LineBreakOptions._fromFFI is not meant to be called externally. Please use the default constructor."); } var structObj = {}; const strictnessDeref = ptr; structObj.strictness = diplomatRuntime.readOption(wasm, strictnessDeref, 4, (wasm, offset) => { const deref = diplomatRuntime.enumDiscriminant(wasm, offset); return new LineBreakStrictness(diplomatRuntime.internalConstructor, deref) }); const wordOptionDeref = ptr + 8; structObj.wordOption = diplomatRuntime.readOption(wasm, wordOptionDeref, 4, (wasm, offset) => { const deref = diplomatRuntime.enumDiscriminant(wasm, offset); return new LineBreakWordOption(diplomatRuntime.internalConstructor, deref) }); return new LineBreakOptions(structObj, internalConstructor); } }