// 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/2.2.0/icu/properties/props/struct.GeneralCategoryGroup.html) for more information.
 */
export class GeneralCategoryGroup {
    #mask;
    get mask() {
        return this.#mask;
    }
    set mask(value){
        this.#mask = value;
    }
    /** @internal */
    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(
        dst,
        functionCleanupArena,
        appendArrayMap
    ) {
        return this.#mask;
    }

    static get _sizeBytes() {
        return 4;
    }

    /// Currently unused, we may want to use later on though:
    static get _sizeAlign() {
        return 4;
    }

    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/2.2.0/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(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(GeneralCategoryGroup._sizeBytes), functionCleanupArena, {}, false), val.ffiValue);

        try {
            return result;
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            functionCleanupArena.free();

        }
    }

    /**
     * See the [Rust documentation for `complement`](https://docs.rs/icu/2.2.0/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(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(GeneralCategoryGroup._sizeBytes), functionCleanupArena, {}, false));

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            functionCleanupArena.free();

        }
    }

    /**
     * See the [Rust documentation for `all`](https://docs.rs/icu/2.2.0/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 {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `empty`](https://docs.rs/icu/2.2.0/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 {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `union`](https://docs.rs/icu/2.2.0/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(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(GeneralCategoryGroup._sizeBytes), functionCleanupArena, {}, false), GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, other)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(GeneralCategoryGroup._sizeBytes), functionCleanupArena, {}, false));

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            functionCleanupArena.free();

        }
    }

    /**
     * See the [Rust documentation for `intersection`](https://docs.rs/icu/2.2.0/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(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(GeneralCategoryGroup._sizeBytes), functionCleanupArena, {}, false), GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, other)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(GeneralCategoryGroup._sizeBytes), functionCleanupArena, {}, false));

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            functionCleanupArena.free();

        }
    }

    /**
     * See the [Rust documentation for `CasedLetter`](https://docs.rs/icu/2.2.0/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 {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `Letter`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Letter) for more information.
     */
    static letter() {

        const result = wasm.icu4x_GeneralCategoryGroup_letter_mv1();

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `Mark`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Mark) for more information.
     */
    static mark() {

        const result = wasm.icu4x_GeneralCategoryGroup_mark_mv1();

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `Number`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Number) for more information.
     */
    static number() {

        const result = wasm.icu4x_GeneralCategoryGroup_number_mv1();

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `Other`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Other) for more information.
     */
    static separator() {

        const result = wasm.icu4x_GeneralCategoryGroup_separator_mv1();

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `Letter`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Letter) for more information.
     */
    static other() {

        const result = wasm.icu4x_GeneralCategoryGroup_other_mv1();

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `Punctuation`](https://docs.rs/icu/2.2.0/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 {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * See the [Rust documentation for `Symbol`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Symbol) for more information.
     */
    static symbol() {

        const result = wasm.icu4x_GeneralCategoryGroup_symbol_mv1();

        try {
            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    constructor(structObj) {
        return this.#internalConstructor(...arguments)
    }
}