tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GeneralCategoryGroup.mjs (10297B)


      1 // generated by diplomat-tool
      2 import { GeneralCategory } from "./GeneralCategory.mjs"
      3 import wasm from "./diplomat-wasm.mjs";
      4 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      5 
      6 
      7 /**
      8 * A mask that is capable of representing groups of `General_Category` values.
      9 *
     10 * See the [Rust documentation for `GeneralCategoryGroup`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html) for more information.
     11 */
     12 
     13 
     14 export class GeneralCategoryGroup {
     15    #mask;
     16    get mask() {
     17        return this.#mask;
     18    }
     19    set mask(value){
     20        this.#mask = value;
     21    }
     22    /** Create `GeneralCategoryGroup` from an object that contains all of `GeneralCategoryGroup`s fields.
     23    * Optional fields do not need to be included in the provided object.
     24    */
     25    static fromFields(structObj) {
     26        return new GeneralCategoryGroup(structObj);
     27    }
     28 
     29    #internalConstructor(structObj) {
     30        if (typeof structObj !== "object") {
     31            throw new Error("GeneralCategoryGroup's constructor takes an object of GeneralCategoryGroup's fields.");
     32        }
     33 
     34        if ("mask" in structObj) {
     35            this.#mask = structObj.mask;
     36        } else {
     37            throw new Error("Missing required field mask.");
     38        }
     39 
     40        return this;
     41    }
     42 
     43    // Return this struct in FFI function friendly format.
     44    // Returns an array that can be expanded with spread syntax (...)
     45    _intoFFI(
     46        functionCleanupArena,
     47        appendArrayMap
     48    ) {
     49        return [this.#mask]
     50    }
     51 
     52    static _fromSuppliedValue(internalConstructor, obj) {
     53        if (internalConstructor !== diplomatRuntime.internalConstructor) {
     54            throw new Error("_fromSuppliedValue cannot be called externally.");
     55        }
     56 
     57        if (obj instanceof GeneralCategoryGroup) {
     58            return obj;
     59        }
     60 
     61        return GeneralCategoryGroup.fromFields(obj);
     62    }
     63 
     64    _writeToArrayBuffer(
     65        arrayBuffer,
     66        offset,
     67        functionCleanupArena,
     68        appendArrayMap
     69    ) {
     70        diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#mask, Uint32Array);
     71    }
     72 
     73    // This struct contains borrowed fields, so this takes in a list of
     74    // "edges" corresponding to where each lifetime's data may have been borrowed from
     75    // and passes it down to individual fields containing the borrow.
     76    // This method does not attempt to handle any dependencies between lifetimes, the caller
     77    // should handle this when constructing edge arrays.
     78    static _fromFFI(internalConstructor, primitiveValue) {
     79        if (internalConstructor !== diplomatRuntime.internalConstructor) {
     80            throw new Error("GeneralCategoryGroup._fromFFI is not meant to be called externally. Please use the default constructor.");
     81        }
     82        let structObj = {};
     83        structObj.mask = primitiveValue;
     84 
     85        return new GeneralCategoryGroup(structObj);
     86    }
     87 
     88 
     89    /**
     90     * See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.contains) for more information.
     91     */
     92    contains(val) {
     93        let functionCleanupArena = new diplomatRuntime.CleanupArena();
     94 
     95 
     96        const result = wasm.icu4x_GeneralCategoryGroup_contains_mv1(...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, this)._intoFFI(functionCleanupArena, {}), val.ffiValue);
     97 
     98        try {
     99            return result;
    100        }
    101 
    102        finally {
    103            functionCleanupArena.free();
    104 
    105        }
    106    }
    107 
    108    /**
    109     * See the [Rust documentation for `complement`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.complement) for more information.
    110     */
    111    complement() {
    112        let functionCleanupArena = new diplomatRuntime.CleanupArena();
    113 
    114 
    115        const result = wasm.icu4x_GeneralCategoryGroup_complement_mv1(...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, this)._intoFFI(functionCleanupArena, {}));
    116 
    117        try {
    118            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    119        }
    120 
    121        finally {
    122            functionCleanupArena.free();
    123 
    124        }
    125    }
    126 
    127    /**
    128     * See the [Rust documentation for `all`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.all) for more information.
    129     */
    130    static all() {
    131 
    132        const result = wasm.icu4x_GeneralCategoryGroup_all_mv1();
    133 
    134        try {
    135            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    136        }
    137 
    138        finally {
    139        }
    140    }
    141 
    142    /**
    143     * See the [Rust documentation for `empty`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.empty) for more information.
    144     */
    145    static empty() {
    146 
    147        const result = wasm.icu4x_GeneralCategoryGroup_empty_mv1();
    148 
    149        try {
    150            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    151        }
    152 
    153        finally {
    154        }
    155    }
    156 
    157    /**
    158     * See the [Rust documentation for `union`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.union) for more information.
    159     */
    160    union(other) {
    161        let functionCleanupArena = new diplomatRuntime.CleanupArena();
    162 
    163 
    164        const result = wasm.icu4x_GeneralCategoryGroup_union_mv1(...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, this)._intoFFI(functionCleanupArena, {}), ...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, other)._intoFFI(functionCleanupArena, {}));
    165 
    166        try {
    167            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    168        }
    169 
    170        finally {
    171            functionCleanupArena.free();
    172 
    173        }
    174    }
    175 
    176    /**
    177     * See the [Rust documentation for `intersection`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#method.intersection) for more information.
    178     */
    179    intersection(other) {
    180        let functionCleanupArena = new diplomatRuntime.CleanupArena();
    181 
    182 
    183        const result = wasm.icu4x_GeneralCategoryGroup_intersection_mv1(...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, this)._intoFFI(functionCleanupArena, {}), ...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, other)._intoFFI(functionCleanupArena, {}));
    184 
    185        try {
    186            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    187        }
    188 
    189        finally {
    190            functionCleanupArena.free();
    191 
    192        }
    193    }
    194 
    195    /**
    196     * See the [Rust documentation for `CasedLetter`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.CasedLetter) for more information.
    197     */
    198    static casedLetter() {
    199 
    200        const result = wasm.icu4x_GeneralCategoryGroup_cased_letter_mv1();
    201 
    202        try {
    203            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    204        }
    205 
    206        finally {
    207        }
    208    }
    209 
    210    /**
    211     * See the [Rust documentation for `Letter`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Letter) for more information.
    212     */
    213    static letter() {
    214 
    215        const result = wasm.icu4x_GeneralCategoryGroup_letter_mv1();
    216 
    217        try {
    218            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    219        }
    220 
    221        finally {
    222        }
    223    }
    224 
    225    /**
    226     * See the [Rust documentation for `Mark`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Mark) for more information.
    227     */
    228    static mark() {
    229 
    230        const result = wasm.icu4x_GeneralCategoryGroup_mark_mv1();
    231 
    232        try {
    233            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    234        }
    235 
    236        finally {
    237        }
    238    }
    239 
    240    /**
    241     * See the [Rust documentation for `Number`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Number) for more information.
    242     */
    243    static number() {
    244 
    245        const result = wasm.icu4x_GeneralCategoryGroup_number_mv1();
    246 
    247        try {
    248            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    249        }
    250 
    251        finally {
    252        }
    253    }
    254 
    255    /**
    256     * See the [Rust documentation for `Other`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Other) for more information.
    257     */
    258    static separator() {
    259 
    260        const result = wasm.icu4x_GeneralCategoryGroup_separator_mv1();
    261 
    262        try {
    263            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    264        }
    265 
    266        finally {
    267        }
    268    }
    269 
    270    /**
    271     * See the [Rust documentation for `Letter`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Letter) for more information.
    272     */
    273    static other() {
    274 
    275        const result = wasm.icu4x_GeneralCategoryGroup_other_mv1();
    276 
    277        try {
    278            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    279        }
    280 
    281        finally {
    282        }
    283    }
    284 
    285    /**
    286     * See the [Rust documentation for `Punctuation`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Punctuation) for more information.
    287     */
    288    static punctuation() {
    289 
    290        const result = wasm.icu4x_GeneralCategoryGroup_punctuation_mv1();
    291 
    292        try {
    293            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    294        }
    295 
    296        finally {
    297        }
    298    }
    299 
    300    /**
    301     * See the [Rust documentation for `Symbol`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategoryGroup.html#associatedconstant.Symbol) for more information.
    302     */
    303    static symbol() {
    304 
    305        const result = wasm.icu4x_GeneralCategoryGroup_symbol_mv1();
    306 
    307        try {
    308            return GeneralCategoryGroup._fromFFI(diplomatRuntime.internalConstructor, result);
    309        }
    310 
    311        finally {
    312        }
    313    }
    314 
    315    constructor(structObj) {
    316        return this.#internalConstructor(...arguments)
    317    }
    318 }