Source code

Revision control

Copy as Markdown

Other Tools

// generated by diplomat-tool
import { GeneralCategory } from "./GeneralCategory.mjs"
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";
/**
* A mask that is capable of representing groups of `General_Category` values.
*
* See the [Rust documentation for `GeneralCategoryGroup`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html) for more information.
*/
export class GeneralCategoryGroup {
#mask;
get mask() {
return this.#mask;
}
set mask(value){
this.#mask = value;
}
/** Create `GeneralCategoryGroup` from an object that contains all of `GeneralCategoryGroup`s fields.
* Optional fields do not need to be included in the provided object.
*/
static fromFields(structObj) {
return new GeneralCategoryGroup(structObj);
}
#internalConstructor(structObj) {
if (typeof structObj !== "object") {
throw new Error("GeneralCategoryGroup's constructor takes an object of GeneralCategoryGroup's fields.");
}
if ("mask" in structObj) {
this.#mask = structObj.mask;
} else {
throw new Error("Missing required field mask.");
}
return this;
}
// Return this struct in FFI function friendly format.
// Returns an array that can be expanded with spread syntax (...)
_intoFFI(
functionCleanupArena,
appendArrayMap
) {
return [this.#mask]
}
static _fromSuppliedValue(internalConstructor, obj) {
if (internalConstructor !== diplomatRuntime.internalConstructor) {
throw new Error("_fromSuppliedValue cannot be called externally.");
}
if (obj instanceof GeneralCategoryGroup) {
return obj;
}
return GeneralCategoryGroup.fromFields(obj);
}
_writeToArrayBuffer(
arrayBuffer,
offset,
functionCleanupArena,
appendArrayMap
) {
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#mask, Uint32Array);
}
// 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, primitiveValue) {
if (internalConstructor !== diplomatRuntime.internalConstructor) {
throw new Error("GeneralCategoryGroup._fromFFI is not meant to be called externally. Please use the default constructor.");
}
let structObj = {};
structObj.mask = primitiveValue;
return new GeneralCategoryGroup(structObj);
}
/**
* See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.contains) for more information.
*/
contains(val) {
let functionCleanupArena = new diplomatRuntime.CleanupArena();
const result = wasm.icu4x_GeneralCategoryGroup_contains_mv1(...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, this)._intoFFI(functionCleanupArena, {}), val.ffiValue);
try {
return result;
}
finally {
functionCleanupArena.free();
}
}
/**
* See the [Rust documentation for `complement`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.complement) for more information.
*/
complement() {
let functionCleanupArena = new diplomatRuntime.CleanupArena();
const result = wasm.icu4x_GeneralCategoryGroup_complement_mv1(...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, this)._intoFFI(functionCleanupArena, {}));
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
functionCleanupArena.free();
}
}
/**
* See the [Rust documentation for `all`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.all) for more information.
*/
static all() {
const result = wasm.icu4x_GeneralCategoryGroup_all_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
* See the [Rust documentation for `empty`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.empty) for more information.
*/
static empty() {
const result = wasm.icu4x_GeneralCategoryGroup_empty_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
* See the [Rust documentation for `union`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.union) for more information.
*/
union(other) {
let functionCleanupArena = new diplomatRuntime.CleanupArena();
const result = wasm.icu4x_GeneralCategoryGroup_union_mv1(...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, this)._intoFFI(functionCleanupArena, {}), ...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, other)._intoFFI(functionCleanupArena, {}));
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
functionCleanupArena.free();
}
}
/**
* See the [Rust documentation for `intersection`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.intersection) for more information.
*/
intersection(other) {
let functionCleanupArena = new diplomatRuntime.CleanupArena();
const result = wasm.icu4x_GeneralCategoryGroup_intersection_mv1(...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, this)._intoFFI(functionCleanupArena, {}), ...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, other)._intoFFI(functionCleanupArena, {}));
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
functionCleanupArena.free();
}
}
/**
* See the [Rust documentation for `CasedLetter`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.CasedLetter) for more information.
*/
static casedLetter() {
const result = wasm.icu4x_GeneralCategoryGroup_cased_letter_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
*/
static letter() {
const result = wasm.icu4x_GeneralCategoryGroup_letter_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
*/
static mark() {
const result = wasm.icu4x_GeneralCategoryGroup_mark_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
*/
static number() {
const result = wasm.icu4x_GeneralCategoryGroup_number_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
*/
static separator() {
const result = wasm.icu4x_GeneralCategoryGroup_separator_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
*/
static other() {
const result = wasm.icu4x_GeneralCategoryGroup_other_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
* See the [Rust documentation for `Punctuation`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Punctuation) for more information.
*/
static punctuation() {
const result = wasm.icu4x_GeneralCategoryGroup_punctuation_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
/**
*/
static symbol() {
const result = wasm.icu4x_GeneralCategoryGroup_symbol_mv1();
try {
return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
}
finally {
}
}
constructor(structObj) {
return this.#internalConstructor(...arguments)
}
}