// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!

import {
  ArrayBufferDataStream,
  FfiConverter,
  FfiConverterArrayBuffer,
  FfiConverterInt8,
  FfiConverterUInt8,
  FfiConverterInt16,
  FfiConverterUInt16,
  FfiConverterInt32,
  FfiConverterUInt32,
  FfiConverterInt64,
  FfiConverterUInt64,
  FfiConverterFloat32,
  FfiConverterFloat64,
  FfiConverterBoolean,
  FfiConverterBytes,
  FfiConverterString,
  UniFFICallbackHandler,
  UniFFICallbackMethodHandler,
  UniFFIError,
  UniFFIInternalError,
  UniFFITypeError,
  constructUniffiObject,
  handleRustResult,
  uniffiObjectPtr,
} from "moz-src:///toolkit/components/uniffi-js/js/UniFFI.sys.mjs";

// Objects intended to be used in the unit tests
export var UnitTestObjs = {
    uniffiObjectPtr,
};





// Export the FFIConverter object to make external types work.
export class FfiConverterOptionalUInt64 extends FfiConverterArrayBuffer {
    static checkType(value) {
        if (value !== undefined && value !== null) {
            FfiConverterUInt64.checkType(value)
        }
    }

    static read(dataStream) {
        const code = dataStream.readUint8(0);
        switch (code) {
            case 0:
                return null
            case 1:
                return FfiConverterUInt64.read(dataStream)
            default:
                throw new UniFFIError(`Unexpected code: ${code}`);
        }
    }

    static write(dataStream, value) {
        if (value === null || value === undefined) {
            dataStream.writeUint8(0);
            return;
        }
        dataStream.writeUint8(1);
        FfiConverterUInt64.write(dataStream, value)
    }

    static computeSize(value) {
        if (value === null || value === undefined) {
            return 1;
        }
        return 1 + FfiConverterUInt64.computeSize(value)
    }
}
/**
 * MozAdsCacheConfig
 */
export class MozAdsCacheConfig {
    constructor(
        {
            dbPath, 
            defaultCacheTtlSeconds= null, 
            maxSizeMib= null
        } = {
            dbPath: undefined, 
            defaultCacheTtlSeconds: undefined, 
            maxSizeMib: undefined
        }
    ) {
        try {
            FfiConverterString.checkType(dbPath)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("dbPath");
            }
            throw e;
        }
        try {
            FfiConverterOptionalUInt64.checkType(defaultCacheTtlSeconds)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("defaultCacheTtlSeconds");
            }
            throw e;
        }
        try {
            FfiConverterOptionalUInt64.checkType(maxSizeMib)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("maxSizeMib");
            }
            throw e;
        }
        /**
         * @type {string}
         */
        this.dbPath = dbPath;
        /**
         * @type {?number}
         */
        this.defaultCacheTtlSeconds = defaultCacheTtlSeconds;
        /**
         * @type {?number}
         */
        this.maxSizeMib = maxSizeMib;
    }

    equals(other) {
        return (
            this.dbPath == other.dbPath
            && this.defaultCacheTtlSeconds == other.defaultCacheTtlSeconds
            && this.maxSizeMib == other.maxSizeMib
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsCacheConfig extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsCacheConfig({
            dbPath: FfiConverterString.read(dataStream),
            defaultCacheTtlSeconds: FfiConverterOptionalUInt64.read(dataStream),
            maxSizeMib: FfiConverterOptionalUInt64.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterString.write(dataStream, value.dbPath);
        FfiConverterOptionalUInt64.write(dataStream, value.defaultCacheTtlSeconds);
        FfiConverterOptionalUInt64.write(dataStream, value.maxSizeMib);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterString.computeSize(value.dbPath);
        totalSize += FfiConverterOptionalUInt64.computeSize(value.defaultCacheTtlSeconds);
        totalSize += FfiConverterOptionalUInt64.computeSize(value.maxSizeMib);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsCacheConfig)) {
            throw new UniFFITypeError(`Expected 'MozAdsCacheConfig', found '${typeof value}'`);
        }
        try {
            FfiConverterString.checkType(value.dbPath);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".dbPath");
            }
            throw e;
        }
        try {
            FfiConverterOptionalUInt64.checkType(value.defaultCacheTtlSeconds);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".defaultCacheTtlSeconds");
            }
            throw e;
        }
        try {
            FfiConverterOptionalUInt64.checkType(value.maxSizeMib);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".maxSizeMib");
            }
            throw e;
        }
    }
}

/**
 * MozAdsCacheMode
 */
export const MozAdsCacheMode = Object.freeze({
    /**
     * CACHE_FIRST
     */
    CACHE_FIRST: 0,
    /**
     * NETWORK_FIRST
     */
    NETWORK_FIRST: 1,
});

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsCacheMode extends FfiConverterArrayBuffer {
    static #validValues = Object.values(MozAdsCacheMode)

    static read(dataStream) {
        // Use sequential indices (1-based) for the wire format to match the Rust scaffolding
        switch (dataStream.readInt32()) {
            case 1:
                return MozAdsCacheMode.CACHE_FIRST
            case 2:
                return MozAdsCacheMode.NETWORK_FIRST
            default:
                throw new UniFFITypeError("Unknown MozAdsCacheMode variant");
        }
    }

    static write(dataStream, value) {
        // Use sequential indices (1-based) for the wire format to match the Rust scaffolding
        if (value === MozAdsCacheMode.CACHE_FIRST) {
            dataStream.writeInt32(1);
            return;
        }
        if (value === MozAdsCacheMode.NETWORK_FIRST) {
            dataStream.writeInt32(2);
            return;
        }
        throw new UniFFITypeError("Unknown MozAdsCacheMode variant");
    }

    static computeSize(value) {
        return 4;
    }

    static checkType(value) {
      // Check that the value is a valid enum variant
      if (!this.#validValues.includes(value)) {
          throw new UniFFITypeError(`${value} is not a valid value for MozAdsCacheMode`);
      }
    }
}
/**
 * MozAdsCachePolicy
 */
export class MozAdsCachePolicy {
    constructor(
        {
            mode, 
            ttlSeconds= null
        } = {
            mode: undefined, 
            ttlSeconds: undefined
        }
    ) {
        try {
            FfiConverterTypeMozAdsCacheMode.checkType(mode)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("mode");
            }
            throw e;
        }
        try {
            FfiConverterOptionalUInt64.checkType(ttlSeconds)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("ttlSeconds");
            }
            throw e;
        }
        /**
         * @type {MozAdsCacheMode[keyof MozAdsCacheMode]}
         */
        this.mode = mode;
        /**
         * @type {?number}
         */
        this.ttlSeconds = ttlSeconds;
    }

    equals(other) {
        return (
            this.mode == other.mode
            && this.ttlSeconds == other.ttlSeconds
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsCachePolicy extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsCachePolicy({
            mode: FfiConverterTypeMozAdsCacheMode.read(dataStream),
            ttlSeconds: FfiConverterOptionalUInt64.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterTypeMozAdsCacheMode.write(dataStream, value.mode);
        FfiConverterOptionalUInt64.write(dataStream, value.ttlSeconds);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterTypeMozAdsCacheMode.computeSize(value.mode);
        totalSize += FfiConverterOptionalUInt64.computeSize(value.ttlSeconds);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsCachePolicy)) {
            throw new UniFFITypeError(`Expected 'MozAdsCachePolicy', found '${typeof value}'`);
        }
        try {
            FfiConverterTypeMozAdsCacheMode.checkType(value.mode);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".mode");
            }
            throw e;
        }
        try {
            FfiConverterOptionalUInt64.checkType(value.ttlSeconds);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".ttlSeconds");
            }
            throw e;
        }
    }
}


/**
 * MozAdsCallbackOptions
 */
export class MozAdsCallbackOptions {
    constructor(
        {
            ohttp= false
        } = {
            ohttp: undefined
        }
    ) {
        try {
            FfiConverterBoolean.checkType(ohttp)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("ohttp");
            }
            throw e;
        }
        /**
         * @type {boolean}
         */
        this.ohttp = ohttp;
    }

    equals(other) {
        return (
            this.ohttp == other.ohttp
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsCallbackOptions extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsCallbackOptions({
            ohttp: FfiConverterBoolean.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterBoolean.write(dataStream, value.ohttp);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterBoolean.computeSize(value.ohttp);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsCallbackOptions)) {
            throw new UniFFITypeError(`Expected 'MozAdsCallbackOptions', found '${typeof value}'`);
        }
        try {
            FfiConverterBoolean.checkType(value.ohttp);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".ohttp");
            }
            throw e;
        }
    }
}
export class FfiConverterTypeAdsClientUrl extends FfiConverter {
    static lift(value) {
        return FfiConverterString.lift(value);
    }

    static lower(value) {
        return FfiConverterString.lower(value);
    }

    static write(dataStream, value) {
        FfiConverterString.write(dataStream, value);
    }

    static read(dataStream) {
        const builtinVal = FfiConverterString.read(dataStream);
        return builtinVal;
    }

    static computeSize(value) {
        return FfiConverterString.computeSize(value);
    }

    static checkType(value) {
        if (value === null || value === undefined) {
            throw new TypeError("value is null or undefined");
        }
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterOptionalTypeAdsClientUrl extends FfiConverterArrayBuffer {
    static checkType(value) {
        if (value !== undefined && value !== null) {
            FfiConverterTypeAdsClientUrl.checkType(value)
        }
    }

    static read(dataStream) {
        const code = dataStream.readUint8(0);
        switch (code) {
            case 0:
                return null
            case 1:
                return FfiConverterTypeAdsClientUrl.read(dataStream)
            default:
                throw new UniFFIError(`Unexpected code: ${code}`);
        }
    }

    static write(dataStream, value) {
        if (value === null || value === undefined) {
            dataStream.writeUint8(0);
            return;
        }
        dataStream.writeUint8(1);
        FfiConverterTypeAdsClientUrl.write(dataStream, value)
    }

    static computeSize(value) {
        if (value === null || value === undefined) {
            return 1;
        }
        return 1 + FfiConverterTypeAdsClientUrl.computeSize(value)
    }
}
/**
 * MozAdsCallbacks
 */
export class MozAdsCallbacks {
    constructor(
        {
            click, 
            impression, 
            report
        } = {
            click: undefined, 
            impression: undefined, 
            report: undefined
        }
    ) {
        try {
            FfiConverterTypeAdsClientUrl.checkType(click)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("click");
            }
            throw e;
        }
        try {
            FfiConverterTypeAdsClientUrl.checkType(impression)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("impression");
            }
            throw e;
        }
        try {
            FfiConverterOptionalTypeAdsClientUrl.checkType(report)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("report");
            }
            throw e;
        }
        /**
         * @type {AdsClientUrl}
         */
        this.click = click;
        /**
         * @type {AdsClientUrl}
         */
        this.impression = impression;
        /**
         * @type {?AdsClientUrl}
         */
        this.report = report;
    }

    equals(other) {
        return (
            this.click == other.click
            && this.impression == other.impression
            && this.report == other.report
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsCallbacks extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsCallbacks({
            click: FfiConverterTypeAdsClientUrl.read(dataStream),
            impression: FfiConverterTypeAdsClientUrl.read(dataStream),
            report: FfiConverterOptionalTypeAdsClientUrl.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterTypeAdsClientUrl.write(dataStream, value.click);
        FfiConverterTypeAdsClientUrl.write(dataStream, value.impression);
        FfiConverterOptionalTypeAdsClientUrl.write(dataStream, value.report);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterTypeAdsClientUrl.computeSize(value.click);
        totalSize += FfiConverterTypeAdsClientUrl.computeSize(value.impression);
        totalSize += FfiConverterOptionalTypeAdsClientUrl.computeSize(value.report);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsCallbacks)) {
            throw new UniFFITypeError(`Expected 'MozAdsCallbacks', found '${typeof value}'`);
        }
        try {
            FfiConverterTypeAdsClientUrl.checkType(value.click);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".click");
            }
            throw e;
        }
        try {
            FfiConverterTypeAdsClientUrl.checkType(value.impression);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".impression");
            }
            throw e;
        }
        try {
            FfiConverterOptionalTypeAdsClientUrl.checkType(value.report);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".report");
            }
            throw e;
        }
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterSequenceString extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const arr = [];
        for (let i = 0; i < len; i++) {
            arr.push(FfiConverterString.read(dataStream));
        }
        return arr;
    }

    static write(dataStream, value) {
        dataStream.writeInt32(value.length);
        value.forEach((innerValue) => {
            FfiConverterString.write(dataStream, innerValue);
        })
    }

    static computeSize(value) {
        // The size of the length
        let size = 4;
        for (const innerValue of value) {
            size += FfiConverterString.computeSize(innerValue);
        }
        return size;
    }

    static checkType(value) {
        if (!Array.isArray(value)) {
            throw new UniFFITypeError(`${value} is not an array`);
        }
        value.forEach((innerValue, idx) => {
            try {
                FfiConverterString.checkType(innerValue);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${idx}]`);
                }
                throw e;
            }
        })
    }
}

/**
 * MozAdsIabContentTaxonomy
 */
export const MozAdsIabContentTaxonomy = Object.freeze({
    /**
     * IAB1_0
     */
    IAB1_0: 0,
    /**
     * IAB2_0
     */
    IAB2_0: 1,
    /**
     * IAB2_1
     */
    IAB2_1: 2,
    /**
     * IAB2_2
     */
    IAB2_2: 3,
    /**
     * IAB3_0
     */
    IAB3_0: 4,
});

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsIABContentTaxonomy extends FfiConverterArrayBuffer {
    static #validValues = Object.values(MozAdsIabContentTaxonomy)

    static read(dataStream) {
        // Use sequential indices (1-based) for the wire format to match the Rust scaffolding
        switch (dataStream.readInt32()) {
            case 1:
                return MozAdsIabContentTaxonomy.IAB1_0
            case 2:
                return MozAdsIabContentTaxonomy.IAB2_0
            case 3:
                return MozAdsIabContentTaxonomy.IAB2_1
            case 4:
                return MozAdsIabContentTaxonomy.IAB2_2
            case 5:
                return MozAdsIabContentTaxonomy.IAB3_0
            default:
                throw new UniFFITypeError("Unknown MozAdsIabContentTaxonomy variant");
        }
    }

    static write(dataStream, value) {
        // Use sequential indices (1-based) for the wire format to match the Rust scaffolding
        if (value === MozAdsIabContentTaxonomy.IAB1_0) {
            dataStream.writeInt32(1);
            return;
        }
        if (value === MozAdsIabContentTaxonomy.IAB2_0) {
            dataStream.writeInt32(2);
            return;
        }
        if (value === MozAdsIabContentTaxonomy.IAB2_1) {
            dataStream.writeInt32(3);
            return;
        }
        if (value === MozAdsIabContentTaxonomy.IAB2_2) {
            dataStream.writeInt32(4);
            return;
        }
        if (value === MozAdsIabContentTaxonomy.IAB3_0) {
            dataStream.writeInt32(5);
            return;
        }
        throw new UniFFITypeError("Unknown MozAdsIabContentTaxonomy variant");
    }

    static computeSize(value) {
        return 4;
    }

    static checkType(value) {
      // Check that the value is a valid enum variant
      if (!this.#validValues.includes(value)) {
          throw new UniFFITypeError(`${value} is not a valid value for MozAdsIabContentTaxonomy`);
      }
    }
}
/**
 * MozAdsContentCategory
 */
export class MozAdsContentCategory {
    constructor(
        {
            categories, 
            taxonomy
        } = {
            categories: undefined, 
            taxonomy: undefined
        }
    ) {
        try {
            FfiConverterSequenceString.checkType(categories)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("categories");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsIABContentTaxonomy.checkType(taxonomy)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("taxonomy");
            }
            throw e;
        }
        /**
         * @type {Array.<string>}
         */
        this.categories = categories;
        /**
         * @type {MozAdsIabContentTaxonomy[keyof MozAdsIabContentTaxonomy]}
         */
        this.taxonomy = taxonomy;
    }

    equals(other) {
        return (
            this.categories == other.categories
            && this.taxonomy == other.taxonomy
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsContentCategory extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsContentCategory({
            categories: FfiConverterSequenceString.read(dataStream),
            taxonomy: FfiConverterTypeMozAdsIABContentTaxonomy.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterSequenceString.write(dataStream, value.categories);
        FfiConverterTypeMozAdsIABContentTaxonomy.write(dataStream, value.taxonomy);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterSequenceString.computeSize(value.categories);
        totalSize += FfiConverterTypeMozAdsIABContentTaxonomy.computeSize(value.taxonomy);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsContentCategory)) {
            throw new UniFFITypeError(`Expected 'MozAdsContentCategory', found '${typeof value}'`);
        }
        try {
            FfiConverterSequenceString.checkType(value.categories);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".categories");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsIABContentTaxonomy.checkType(value.taxonomy);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".taxonomy");
            }
            throw e;
        }
    }
}
/**
 * MozAdsIabContent
 */
export class MozAdsIabContent {
    constructor(
        {
            categoryIds, 
            taxonomy
        } = {
            categoryIds: undefined, 
            taxonomy: undefined
        }
    ) {
        try {
            FfiConverterSequenceString.checkType(categoryIds)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("categoryIds");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsIABContentTaxonomy.checkType(taxonomy)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("taxonomy");
            }
            throw e;
        }
        /**
         * @type {Array.<string>}
         */
        this.categoryIds = categoryIds;
        /**
         * @type {MozAdsIabContentTaxonomy[keyof MozAdsIabContentTaxonomy]}
         */
        this.taxonomy = taxonomy;
    }

    equals(other) {
        return (
            this.categoryIds == other.categoryIds
            && this.taxonomy == other.taxonomy
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsIABContent extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsIabContent({
            categoryIds: FfiConverterSequenceString.read(dataStream),
            taxonomy: FfiConverterTypeMozAdsIABContentTaxonomy.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterSequenceString.write(dataStream, value.categoryIds);
        FfiConverterTypeMozAdsIABContentTaxonomy.write(dataStream, value.taxonomy);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterSequenceString.computeSize(value.categoryIds);
        totalSize += FfiConverterTypeMozAdsIABContentTaxonomy.computeSize(value.taxonomy);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsIabContent)) {
            throw new UniFFITypeError(`Expected 'MozAdsIabContent', found '${typeof value}'`);
        }
        try {
            FfiConverterSequenceString.checkType(value.categoryIds);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".categoryIds");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsIABContentTaxonomy.checkType(value.taxonomy);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".taxonomy");
            }
            throw e;
        }
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterOptionalString extends FfiConverterArrayBuffer {
    static checkType(value) {
        if (value !== undefined && value !== null) {
            FfiConverterString.checkType(value)
        }
    }

    static read(dataStream) {
        const code = dataStream.readUint8(0);
        switch (code) {
            case 0:
                return null
            case 1:
                return FfiConverterString.read(dataStream)
            default:
                throw new UniFFIError(`Unexpected code: ${code}`);
        }
    }

    static write(dataStream, value) {
        if (value === null || value === undefined) {
            dataStream.writeUint8(0);
            return;
        }
        dataStream.writeUint8(1);
        FfiConverterString.write(dataStream, value)
    }

    static computeSize(value) {
        if (value === null || value === undefined) {
            return 1;
        }
        return 1 + FfiConverterString.computeSize(value)
    }
}
/**
 * MozAdsImage
 */
export class MozAdsImage {
    constructor(
        {
            altText, 
            blockKey, 
            callbacks, 
            format, 
            imageUrl, 
            url
        } = {
            altText: undefined, 
            blockKey: undefined, 
            callbacks: undefined, 
            format: undefined, 
            imageUrl: undefined, 
            url: undefined
        }
    ) {
        try {
            FfiConverterOptionalString.checkType(altText)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("altText");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(blockKey)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("blockKey");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsCallbacks.checkType(callbacks)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("callbacks");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(format)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("format");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(imageUrl)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("imageUrl");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(url)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("url");
            }
            throw e;
        }
        /**
         * @type {?string}
         */
        this.altText = altText;
        /**
         * @type {string}
         */
        this.blockKey = blockKey;
        /**
         * @type {MozAdsCallbacks}
         */
        this.callbacks = callbacks;
        /**
         * @type {string}
         */
        this.format = format;
        /**
         * @type {string}
         */
        this.imageUrl = imageUrl;
        /**
         * @type {string}
         */
        this.url = url;
    }

    equals(other) {
        return (
            this.altText == other.altText
            && this.blockKey == other.blockKey
            && this.callbacks.equals(other.callbacks)
            && this.format == other.format
            && this.imageUrl == other.imageUrl
            && this.url == other.url
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsImage extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsImage({
            altText: FfiConverterOptionalString.read(dataStream),
            blockKey: FfiConverterString.read(dataStream),
            callbacks: FfiConverterTypeMozAdsCallbacks.read(dataStream),
            format: FfiConverterString.read(dataStream),
            imageUrl: FfiConverterString.read(dataStream),
            url: FfiConverterString.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterOptionalString.write(dataStream, value.altText);
        FfiConverterString.write(dataStream, value.blockKey);
        FfiConverterTypeMozAdsCallbacks.write(dataStream, value.callbacks);
        FfiConverterString.write(dataStream, value.format);
        FfiConverterString.write(dataStream, value.imageUrl);
        FfiConverterString.write(dataStream, value.url);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterOptionalString.computeSize(value.altText);
        totalSize += FfiConverterString.computeSize(value.blockKey);
        totalSize += FfiConverterTypeMozAdsCallbacks.computeSize(value.callbacks);
        totalSize += FfiConverterString.computeSize(value.format);
        totalSize += FfiConverterString.computeSize(value.imageUrl);
        totalSize += FfiConverterString.computeSize(value.url);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsImage)) {
            throw new UniFFITypeError(`Expected 'MozAdsImage', found '${typeof value}'`);
        }
        try {
            FfiConverterOptionalString.checkType(value.altText);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".altText");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.blockKey);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".blockKey");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsCallbacks.checkType(value.callbacks);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".callbacks");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.format);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".format");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.imageUrl);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".imageUrl");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.url);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".url");
            }
            throw e;
        }
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterOptionalTypeMozAdsIABContent extends FfiConverterArrayBuffer {
    static checkType(value) {
        if (value !== undefined && value !== null) {
            FfiConverterTypeMozAdsIABContent.checkType(value)
        }
    }

    static read(dataStream) {
        const code = dataStream.readUint8(0);
        switch (code) {
            case 0:
                return null
            case 1:
                return FfiConverterTypeMozAdsIABContent.read(dataStream)
            default:
                throw new UniFFIError(`Unexpected code: ${code}`);
        }
    }

    static write(dataStream, value) {
        if (value === null || value === undefined) {
            dataStream.writeUint8(0);
            return;
        }
        dataStream.writeUint8(1);
        FfiConverterTypeMozAdsIABContent.write(dataStream, value)
    }

    static computeSize(value) {
        if (value === null || value === undefined) {
            return 1;
        }
        return 1 + FfiConverterTypeMozAdsIABContent.computeSize(value)
    }
}
/**
 * MozAdsPlacementRequest
 */
export class MozAdsPlacementRequest {
    constructor(
        {
            iabContent= null, 
            placementId
        } = {
            iabContent: undefined, 
            placementId: undefined
        }
    ) {
        try {
            FfiConverterOptionalTypeMozAdsIABContent.checkType(iabContent)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("iabContent");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(placementId)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("placementId");
            }
            throw e;
        }
        /**
         * @type {?MozAdsIabContent}
         */
        this.iabContent = iabContent;
        /**
         * @type {string}
         */
        this.placementId = placementId;
    }

    equals(other) {
        return (
            this.iabContent == other.iabContent
            && this.placementId == other.placementId
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsPlacementRequest extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsPlacementRequest({
            iabContent: FfiConverterOptionalTypeMozAdsIABContent.read(dataStream),
            placementId: FfiConverterString.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterOptionalTypeMozAdsIABContent.write(dataStream, value.iabContent);
        FfiConverterString.write(dataStream, value.placementId);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterOptionalTypeMozAdsIABContent.computeSize(value.iabContent);
        totalSize += FfiConverterString.computeSize(value.placementId);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsPlacementRequest)) {
            throw new UniFFITypeError(`Expected 'MozAdsPlacementRequest', found '${typeof value}'`);
        }
        try {
            FfiConverterOptionalTypeMozAdsIABContent.checkType(value.iabContent);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".iabContent");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.placementId);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".placementId");
            }
            throw e;
        }
    }
}


/**
 * MozAdsPlacementRequestWithCount
 */
export class MozAdsPlacementRequestWithCount {
    constructor(
        {
            count, 
            iabContent= null, 
            placementId
        } = {
            count: undefined, 
            iabContent: undefined, 
            placementId: undefined
        }
    ) {
        try {
            FfiConverterUInt32.checkType(count)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("count");
            }
            throw e;
        }
        try {
            FfiConverterOptionalTypeMozAdsIABContent.checkType(iabContent)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("iabContent");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(placementId)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("placementId");
            }
            throw e;
        }
        /**
         * @type {number}
         */
        this.count = count;
        /**
         * @type {?MozAdsIabContent}
         */
        this.iabContent = iabContent;
        /**
         * @type {string}
         */
        this.placementId = placementId;
    }

    equals(other) {
        return (
            this.count == other.count
            && this.iabContent == other.iabContent
            && this.placementId == other.placementId
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsPlacementRequestWithCount extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsPlacementRequestWithCount({
            count: FfiConverterUInt32.read(dataStream),
            iabContent: FfiConverterOptionalTypeMozAdsIABContent.read(dataStream),
            placementId: FfiConverterString.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterUInt32.write(dataStream, value.count);
        FfiConverterOptionalTypeMozAdsIABContent.write(dataStream, value.iabContent);
        FfiConverterString.write(dataStream, value.placementId);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterUInt32.computeSize(value.count);
        totalSize += FfiConverterOptionalTypeMozAdsIABContent.computeSize(value.iabContent);
        totalSize += FfiConverterString.computeSize(value.placementId);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsPlacementRequestWithCount)) {
            throw new UniFFITypeError(`Expected 'MozAdsPlacementRequestWithCount', found '${typeof value}'`);
        }
        try {
            FfiConverterUInt32.checkType(value.count);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".count");
            }
            throw e;
        }
        try {
            FfiConverterOptionalTypeMozAdsIABContent.checkType(value.iabContent);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".iabContent");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.placementId);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".placementId");
            }
            throw e;
        }
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterOptionalTypeMozAdsCachePolicy extends FfiConverterArrayBuffer {
    static checkType(value) {
        if (value !== undefined && value !== null) {
            FfiConverterTypeMozAdsCachePolicy.checkType(value)
        }
    }

    static read(dataStream) {
        const code = dataStream.readUint8(0);
        switch (code) {
            case 0:
                return null
            case 1:
                return FfiConverterTypeMozAdsCachePolicy.read(dataStream)
            default:
                throw new UniFFIError(`Unexpected code: ${code}`);
        }
    }

    static write(dataStream, value) {
        if (value === null || value === undefined) {
            dataStream.writeUint8(0);
            return;
        }
        dataStream.writeUint8(1);
        FfiConverterTypeMozAdsCachePolicy.write(dataStream, value)
    }

    static computeSize(value) {
        if (value === null || value === undefined) {
            return 1;
        }
        return 1 + FfiConverterTypeMozAdsCachePolicy.computeSize(value)
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterMapStringBoolean extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const map = new Map();
        for (let i = 0; i < len; i++) {
            const key = FfiConverterString.read(dataStream);
            const value = FfiConverterBoolean.read(dataStream);
            map.set(key, value);
        }

        return map;
    }

     static write(dataStream, map) {
        dataStream.writeInt32(map.size);
        for (const [key, value] of map) {
            FfiConverterString.write(dataStream, key);
            FfiConverterBoolean.write(dataStream, value);
        }
    }

    static computeSize(map) {
        // The size of the length
        let size = 4;
        for (const [key, value] of map) {
            size += FfiConverterString.computeSize(key);
            size += FfiConverterBoolean.computeSize(value);
        }
        return size;
    }

    static checkType(map) {
        for (const [key, value] of map) {
            try {
                FfiConverterString.checkType(key);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart("(key)");
                }
                throw e;
            }

            try {
                FfiConverterBoolean.checkType(value);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${key}]`);
                }
                throw e;
            }
        }
    }
}
/**
 * MozAdsRequestOptions
 */
export class MozAdsRequestOptions {
    constructor(
        {
            cachePolicy, 
            flags= {}, 
            ohttp= false
        } = {
            cachePolicy: undefined, 
            flags: undefined, 
            ohttp: undefined
        }
    ) {
        try {
            FfiConverterOptionalTypeMozAdsCachePolicy.checkType(cachePolicy)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("cachePolicy");
            }
            throw e;
        }
        try {
            FfiConverterMapStringBoolean.checkType(flags)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("flags");
            }
            throw e;
        }
        try {
            FfiConverterBoolean.checkType(ohttp)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("ohttp");
            }
            throw e;
        }
        /**
         * @type {?MozAdsCachePolicy}
         */
        this.cachePolicy = cachePolicy;
        /**
         * @type {object}
         */
        this.flags = flags;
        /**
         * @type {boolean}
         */
        this.ohttp = ohttp;
    }

    equals(other) {
        return (
            this.cachePolicy == other.cachePolicy
            && this.flags == other.flags
            && this.ohttp == other.ohttp
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsRequestOptions extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsRequestOptions({
            cachePolicy: FfiConverterOptionalTypeMozAdsCachePolicy.read(dataStream),
            flags: FfiConverterMapStringBoolean.read(dataStream),
            ohttp: FfiConverterBoolean.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterOptionalTypeMozAdsCachePolicy.write(dataStream, value.cachePolicy);
        FfiConverterMapStringBoolean.write(dataStream, value.flags);
        FfiConverterBoolean.write(dataStream, value.ohttp);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterOptionalTypeMozAdsCachePolicy.computeSize(value.cachePolicy);
        totalSize += FfiConverterMapStringBoolean.computeSize(value.flags);
        totalSize += FfiConverterBoolean.computeSize(value.ohttp);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsRequestOptions)) {
            throw new UniFFITypeError(`Expected 'MozAdsRequestOptions', found '${typeof value}'`);
        }
        try {
            FfiConverterOptionalTypeMozAdsCachePolicy.checkType(value.cachePolicy);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".cachePolicy");
            }
            throw e;
        }
        try {
            FfiConverterMapStringBoolean.checkType(value.flags);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".flags");
            }
            throw e;
        }
        try {
            FfiConverterBoolean.checkType(value.ohttp);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".ohttp");
            }
            throw e;
        }
    }
}
/**
 * MozAdsSpocFrequencyCaps
 */
export class MozAdsSpocFrequencyCaps {
    constructor(
        {
            capKey, 
            day
        } = {
            capKey: undefined, 
            day: undefined
        }
    ) {
        try {
            FfiConverterString.checkType(capKey)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("capKey");
            }
            throw e;
        }
        try {
            FfiConverterUInt32.checkType(day)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("day");
            }
            throw e;
        }
        /**
         * @type {string}
         */
        this.capKey = capKey;
        /**
         * @type {number}
         */
        this.day = day;
    }

    equals(other) {
        return (
            this.capKey == other.capKey
            && this.day == other.day
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsSpocFrequencyCaps extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsSpocFrequencyCaps({
            capKey: FfiConverterString.read(dataStream),
            day: FfiConverterUInt32.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterString.write(dataStream, value.capKey);
        FfiConverterUInt32.write(dataStream, value.day);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterString.computeSize(value.capKey);
        totalSize += FfiConverterUInt32.computeSize(value.day);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsSpocFrequencyCaps)) {
            throw new UniFFITypeError(`Expected 'MozAdsSpocFrequencyCaps', found '${typeof value}'`);
        }
        try {
            FfiConverterString.checkType(value.capKey);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".capKey");
            }
            throw e;
        }
        try {
            FfiConverterUInt32.checkType(value.day);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".day");
            }
            throw e;
        }
    }
}


// Export the FFIConverter object to make external types work.
export class FfiConverterMapStringUInt32 extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const map = new Map();
        for (let i = 0; i < len; i++) {
            const key = FfiConverterString.read(dataStream);
            const value = FfiConverterUInt32.read(dataStream);
            map.set(key, value);
        }

        return map;
    }

     static write(dataStream, map) {
        dataStream.writeInt32(map.size);
        for (const [key, value] of map) {
            FfiConverterString.write(dataStream, key);
            FfiConverterUInt32.write(dataStream, value);
        }
    }

    static computeSize(map) {
        // The size of the length
        let size = 4;
        for (const [key, value] of map) {
            size += FfiConverterString.computeSize(key);
            size += FfiConverterUInt32.computeSize(value);
        }
        return size;
    }

    static checkType(map) {
        for (const [key, value] of map) {
            try {
                FfiConverterString.checkType(key);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart("(key)");
                }
                throw e;
            }

            try {
                FfiConverterUInt32.checkType(value);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${key}]`);
                }
                throw e;
            }
        }
    }
}
/**
 * MozAdsSpocRanking
 */
export class MozAdsSpocRanking {
    constructor(
        {
            itemScore, 
            personalizationModels, 
            priority
        } = {
            itemScore: undefined, 
            personalizationModels: undefined, 
            priority: undefined
        }
    ) {
        try {
            FfiConverterFloat64.checkType(itemScore)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("itemScore");
            }
            throw e;
        }
        try {
            FfiConverterMapStringUInt32.checkType(personalizationModels)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("personalizationModels");
            }
            throw e;
        }
        try {
            FfiConverterUInt32.checkType(priority)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("priority");
            }
            throw e;
        }
        /**
         * @type {number}
         */
        this.itemScore = itemScore;
        /**
         * @type {object}
         */
        this.personalizationModels = personalizationModels;
        /**
         * @type {number}
         */
        this.priority = priority;
    }

    equals(other) {
        return (
            this.itemScore == other.itemScore
            && this.personalizationModels == other.personalizationModels
            && this.priority == other.priority
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsSpocRanking extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsSpocRanking({
            itemScore: FfiConverterFloat64.read(dataStream),
            personalizationModels: FfiConverterMapStringUInt32.read(dataStream),
            priority: FfiConverterUInt32.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterFloat64.write(dataStream, value.itemScore);
        FfiConverterMapStringUInt32.write(dataStream, value.personalizationModels);
        FfiConverterUInt32.write(dataStream, value.priority);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterFloat64.computeSize(value.itemScore);
        totalSize += FfiConverterMapStringUInt32.computeSize(value.personalizationModels);
        totalSize += FfiConverterUInt32.computeSize(value.priority);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsSpocRanking)) {
            throw new UniFFITypeError(`Expected 'MozAdsSpocRanking', found '${typeof value}'`);
        }
        try {
            FfiConverterFloat64.checkType(value.itemScore);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".itemScore");
            }
            throw e;
        }
        try {
            FfiConverterMapStringUInt32.checkType(value.personalizationModels);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".personalizationModels");
            }
            throw e;
        }
        try {
            FfiConverterUInt32.checkType(value.priority);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".priority");
            }
            throw e;
        }
    }
}
/**
 * MozAdsSpoc
 */
export class MozAdsSpoc {
    constructor(
        {
            blockKey, 
            callbacks, 
            caps, 
            domain, 
            excerpt, 
            format, 
            imageUrl, 
            ranking, 
            sponsor, 
            sponsoredByOverride, 
            title, 
            url
        } = {
            blockKey: undefined, 
            callbacks: undefined, 
            caps: undefined, 
            domain: undefined, 
            excerpt: undefined, 
            format: undefined, 
            imageUrl: undefined, 
            ranking: undefined, 
            sponsor: undefined, 
            sponsoredByOverride: undefined, 
            title: undefined, 
            url: undefined
        }
    ) {
        try {
            FfiConverterString.checkType(blockKey)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("blockKey");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsCallbacks.checkType(callbacks)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("callbacks");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsSpocFrequencyCaps.checkType(caps)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("caps");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(domain)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("domain");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(excerpt)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("excerpt");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(format)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("format");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(imageUrl)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("imageUrl");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsSpocRanking.checkType(ranking)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("ranking");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(sponsor)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("sponsor");
            }
            throw e;
        }
        try {
            FfiConverterOptionalString.checkType(sponsoredByOverride)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("sponsoredByOverride");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(title)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("title");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(url)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("url");
            }
            throw e;
        }
        /**
         * @type {string}
         */
        this.blockKey = blockKey;
        /**
         * @type {MozAdsCallbacks}
         */
        this.callbacks = callbacks;
        /**
         * @type {MozAdsSpocFrequencyCaps}
         */
        this.caps = caps;
        /**
         * @type {string}
         */
        this.domain = domain;
        /**
         * @type {string}
         */
        this.excerpt = excerpt;
        /**
         * @type {string}
         */
        this.format = format;
        /**
         * @type {string}
         */
        this.imageUrl = imageUrl;
        /**
         * @type {MozAdsSpocRanking}
         */
        this.ranking = ranking;
        /**
         * @type {string}
         */
        this.sponsor = sponsor;
        /**
         * @type {?string}
         */
        this.sponsoredByOverride = sponsoredByOverride;
        /**
         * @type {string}
         */
        this.title = title;
        /**
         * @type {string}
         */
        this.url = url;
    }

    equals(other) {
        return (
            this.blockKey == other.blockKey
            && this.callbacks.equals(other.callbacks)
            && this.caps.equals(other.caps)
            && this.domain == other.domain
            && this.excerpt == other.excerpt
            && this.format == other.format
            && this.imageUrl == other.imageUrl
            && this.ranking.equals(other.ranking)
            && this.sponsor == other.sponsor
            && this.sponsoredByOverride == other.sponsoredByOverride
            && this.title == other.title
            && this.url == other.url
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsSpoc extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsSpoc({
            blockKey: FfiConverterString.read(dataStream),
            callbacks: FfiConverterTypeMozAdsCallbacks.read(dataStream),
            caps: FfiConverterTypeMozAdsSpocFrequencyCaps.read(dataStream),
            domain: FfiConverterString.read(dataStream),
            excerpt: FfiConverterString.read(dataStream),
            format: FfiConverterString.read(dataStream),
            imageUrl: FfiConverterString.read(dataStream),
            ranking: FfiConverterTypeMozAdsSpocRanking.read(dataStream),
            sponsor: FfiConverterString.read(dataStream),
            sponsoredByOverride: FfiConverterOptionalString.read(dataStream),
            title: FfiConverterString.read(dataStream),
            url: FfiConverterString.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterString.write(dataStream, value.blockKey);
        FfiConverterTypeMozAdsCallbacks.write(dataStream, value.callbacks);
        FfiConverterTypeMozAdsSpocFrequencyCaps.write(dataStream, value.caps);
        FfiConverterString.write(dataStream, value.domain);
        FfiConverterString.write(dataStream, value.excerpt);
        FfiConverterString.write(dataStream, value.format);
        FfiConverterString.write(dataStream, value.imageUrl);
        FfiConverterTypeMozAdsSpocRanking.write(dataStream, value.ranking);
        FfiConverterString.write(dataStream, value.sponsor);
        FfiConverterOptionalString.write(dataStream, value.sponsoredByOverride);
        FfiConverterString.write(dataStream, value.title);
        FfiConverterString.write(dataStream, value.url);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterString.computeSize(value.blockKey);
        totalSize += FfiConverterTypeMozAdsCallbacks.computeSize(value.callbacks);
        totalSize += FfiConverterTypeMozAdsSpocFrequencyCaps.computeSize(value.caps);
        totalSize += FfiConverterString.computeSize(value.domain);
        totalSize += FfiConverterString.computeSize(value.excerpt);
        totalSize += FfiConverterString.computeSize(value.format);
        totalSize += FfiConverterString.computeSize(value.imageUrl);
        totalSize += FfiConverterTypeMozAdsSpocRanking.computeSize(value.ranking);
        totalSize += FfiConverterString.computeSize(value.sponsor);
        totalSize += FfiConverterOptionalString.computeSize(value.sponsoredByOverride);
        totalSize += FfiConverterString.computeSize(value.title);
        totalSize += FfiConverterString.computeSize(value.url);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsSpoc)) {
            throw new UniFFITypeError(`Expected 'MozAdsSpoc', found '${typeof value}'`);
        }
        try {
            FfiConverterString.checkType(value.blockKey);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".blockKey");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsCallbacks.checkType(value.callbacks);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".callbacks");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsSpocFrequencyCaps.checkType(value.caps);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".caps");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.domain);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".domain");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.excerpt);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".excerpt");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.format);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".format");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.imageUrl);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".imageUrl");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsSpocRanking.checkType(value.ranking);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".ranking");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.sponsor);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".sponsor");
            }
            throw e;
        }
        try {
            FfiConverterOptionalString.checkType(value.sponsoredByOverride);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".sponsoredByOverride");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.title);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".title");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.url);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".url");
            }
            throw e;
        }
    }
}
/**
 * MozAdsTile
 */
export class MozAdsTile {
    constructor(
        {
            blockKey, 
            callbacks, 
            format, 
            imageUrl, 
            name, 
            url
        } = {
            blockKey: undefined, 
            callbacks: undefined, 
            format: undefined, 
            imageUrl: undefined, 
            name: undefined, 
            url: undefined
        }
    ) {
        try {
            FfiConverterString.checkType(blockKey)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("blockKey");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsCallbacks.checkType(callbacks)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("callbacks");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(format)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("format");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(imageUrl)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("imageUrl");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(name)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("name");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(url)
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart("url");
            }
            throw e;
        }
        /**
         * @type {string}
         */
        this.blockKey = blockKey;
        /**
         * @type {MozAdsCallbacks}
         */
        this.callbacks = callbacks;
        /**
         * @type {string}
         */
        this.format = format;
        /**
         * @type {string}
         */
        this.imageUrl = imageUrl;
        /**
         * @type {string}
         */
        this.name = name;
        /**
         * @type {string}
         */
        this.url = url;
    }

    equals(other) {
        return (
            this.blockKey == other.blockKey
            && this.callbacks.equals(other.callbacks)
            && this.format == other.format
            && this.imageUrl == other.imageUrl
            && this.name == other.name
            && this.url == other.url
        )
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsTile extends FfiConverterArrayBuffer {
    static read(dataStream) {
        return new MozAdsTile({
            blockKey: FfiConverterString.read(dataStream),
            callbacks: FfiConverterTypeMozAdsCallbacks.read(dataStream),
            format: FfiConverterString.read(dataStream),
            imageUrl: FfiConverterString.read(dataStream),
            name: FfiConverterString.read(dataStream),
            url: FfiConverterString.read(dataStream),
        });
    }
    static write(dataStream, value) {
        FfiConverterString.write(dataStream, value.blockKey);
        FfiConverterTypeMozAdsCallbacks.write(dataStream, value.callbacks);
        FfiConverterString.write(dataStream, value.format);
        FfiConverterString.write(dataStream, value.imageUrl);
        FfiConverterString.write(dataStream, value.name);
        FfiConverterString.write(dataStream, value.url);
    }

    static computeSize(value) {
        let totalSize = 0;
        totalSize += FfiConverterString.computeSize(value.blockKey);
        totalSize += FfiConverterTypeMozAdsCallbacks.computeSize(value.callbacks);
        totalSize += FfiConverterString.computeSize(value.format);
        totalSize += FfiConverterString.computeSize(value.imageUrl);
        totalSize += FfiConverterString.computeSize(value.name);
        totalSize += FfiConverterString.computeSize(value.url);
        return totalSize
    }

    static checkType(value) {
        super.checkType(value);
        if (!(value instanceof MozAdsTile)) {
            throw new UniFFITypeError(`Expected 'MozAdsTile', found '${typeof value}'`);
        }
        try {
            FfiConverterString.checkType(value.blockKey);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".blockKey");
            }
            throw e;
        }
        try {
            FfiConverterTypeMozAdsCallbacks.checkType(value.callbacks);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".callbacks");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.format);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".format");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.imageUrl);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".imageUrl");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.name);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".name");
            }
            throw e;
        }
        try {
            FfiConverterString.checkType(value.url);
        } catch (e) {
            if (e instanceof UniFFITypeError) {
                e.addItemDescriptionPart(".url");
            }
            throw e;
        }
    }
}

/**
 * MozAdsClientApiError
 */
export class MozAdsClientApiError extends Error {}


/**
 * Other
 */
export class Other extends MozAdsClientApiError {

    constructor(
        reason,
        ...params
    ) {
        const message = `reason: ${ reason }`;
        super(message, ...params);
        this.reason = reason;
    }
    toString() {
        return `Other: ${super.toString()}`
    }
}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsClientApiError extends FfiConverterArrayBuffer {
    static read(dataStream) {
        switch (dataStream.readInt32()) {
            case 1:
                return new Other(
                    FfiConverterString.read(dataStream)
                    );
            default:
                throw new UniFFITypeError("Unknown MozAdsClientApiError variant");
        }
    }
    static computeSize(value) {
        // Size of the Int indicating the variant
        let totalSize = 4;
        if (value instanceof Other) {
            totalSize += FfiConverterString.computeSize(value.reason);
            return totalSize;
        }
        throw new UniFFITypeError("Unknown MozAdsClientApiError variant");
    }
    static write(dataStream, value) {
        if (value instanceof Other) {
            dataStream.writeInt32(1);
            FfiConverterString.write(dataStream, value.reason);
            return;
        }
        throw new UniFFITypeError("Unknown MozAdsClientApiError variant");
    }

    static errorClass = MozAdsClientApiError;
}

/**
 * MozAdsEnvironment
 */
export const MozAdsEnvironment = Object.freeze({
    /**
     * PROD
     */
    PROD: 0,
    /**
     * STAGING
     */
    STAGING: 1,
});

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsEnvironment extends FfiConverterArrayBuffer {
    static #validValues = Object.values(MozAdsEnvironment)

    static read(dataStream) {
        // Use sequential indices (1-based) for the wire format to match the Rust scaffolding
        switch (dataStream.readInt32()) {
            case 1:
                return MozAdsEnvironment.PROD
            case 2:
                return MozAdsEnvironment.STAGING
            default:
                throw new UniFFITypeError("Unknown MozAdsEnvironment variant");
        }
    }

    static write(dataStream, value) {
        // Use sequential indices (1-based) for the wire format to match the Rust scaffolding
        if (value === MozAdsEnvironment.PROD) {
            dataStream.writeInt32(1);
            return;
        }
        if (value === MozAdsEnvironment.STAGING) {
            dataStream.writeInt32(2);
            return;
        }
        throw new UniFFITypeError("Unknown MozAdsEnvironment variant");
    }

    static computeSize(value) {
        return 4;
    }

    static checkType(value) {
      // Check that the value is a valid enum variant
      if (!this.#validValues.includes(value)) {
          throw new UniFFITypeError(`${value} is not a valid value for MozAdsEnvironment`);
      }
    }
}

/**
 * MozAdsReportReason
 */
export const MozAdsReportReason = Object.freeze({
    /**
     * INAPPROPRIATE
     */
    INAPPROPRIATE: 0,
    /**
     * NOT_INTERESTED
     */
    NOT_INTERESTED: 1,
    /**
     * SEEN_TOO_MANY_TIMES
     */
    SEEN_TOO_MANY_TIMES: 2,
});

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsReportReason extends FfiConverterArrayBuffer {
    static #validValues = Object.values(MozAdsReportReason)

    static read(dataStream) {
        // Use sequential indices (1-based) for the wire format to match the Rust scaffolding
        switch (dataStream.readInt32()) {
            case 1:
                return MozAdsReportReason.INAPPROPRIATE
            case 2:
                return MozAdsReportReason.NOT_INTERESTED
            case 3:
                return MozAdsReportReason.SEEN_TOO_MANY_TIMES
            default:
                throw new UniFFITypeError("Unknown MozAdsReportReason variant");
        }
    }

    static write(dataStream, value) {
        // Use sequential indices (1-based) for the wire format to match the Rust scaffolding
        if (value === MozAdsReportReason.INAPPROPRIATE) {
            dataStream.writeInt32(1);
            return;
        }
        if (value === MozAdsReportReason.NOT_INTERESTED) {
            dataStream.writeInt32(2);
            return;
        }
        if (value === MozAdsReportReason.SEEN_TOO_MANY_TIMES) {
            dataStream.writeInt32(3);
            return;
        }
        throw new UniFFITypeError("Unknown MozAdsReportReason variant");
    }

    static computeSize(value) {
        return 4;
    }

    static checkType(value) {
      // Check that the value is a valid enum variant
      if (!this.#validValues.includes(value)) {
          throw new UniFFITypeError(`${value} is not a valid value for MozAdsReportReason`);
      }
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterOptionalTypeMozAdsCallbackOptions extends FfiConverterArrayBuffer {
    static checkType(value) {
        if (value !== undefined && value !== null) {
            FfiConverterTypeMozAdsCallbackOptions.checkType(value)
        }
    }

    static read(dataStream) {
        const code = dataStream.readUint8(0);
        switch (code) {
            case 0:
                return null
            case 1:
                return FfiConverterTypeMozAdsCallbackOptions.read(dataStream)
            default:
                throw new UniFFIError(`Unexpected code: ${code}`);
        }
    }

    static write(dataStream, value) {
        if (value === null || value === undefined) {
            dataStream.writeUint8(0);
            return;
        }
        dataStream.writeUint8(1);
        FfiConverterTypeMozAdsCallbackOptions.write(dataStream, value)
    }

    static computeSize(value) {
        if (value === null || value === undefined) {
            return 1;
        }
        return 1 + FfiConverterTypeMozAdsCallbackOptions.computeSize(value)
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterSequenceTypeMozAdsPlacementRequest extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const arr = [];
        for (let i = 0; i < len; i++) {
            arr.push(FfiConverterTypeMozAdsPlacementRequest.read(dataStream));
        }
        return arr;
    }

    static write(dataStream, value) {
        dataStream.writeInt32(value.length);
        value.forEach((innerValue) => {
            FfiConverterTypeMozAdsPlacementRequest.write(dataStream, innerValue);
        })
    }

    static computeSize(value) {
        // The size of the length
        let size = 4;
        for (const innerValue of value) {
            size += FfiConverterTypeMozAdsPlacementRequest.computeSize(innerValue);
        }
        return size;
    }

    static checkType(value) {
        if (!Array.isArray(value)) {
            throw new UniFFITypeError(`${value} is not an array`);
        }
        value.forEach((innerValue, idx) => {
            try {
                FfiConverterTypeMozAdsPlacementRequest.checkType(innerValue);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${idx}]`);
                }
                throw e;
            }
        })
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterOptionalTypeMozAdsRequestOptions extends FfiConverterArrayBuffer {
    static checkType(value) {
        if (value !== undefined && value !== null) {
            FfiConverterTypeMozAdsRequestOptions.checkType(value)
        }
    }

    static read(dataStream) {
        const code = dataStream.readUint8(0);
        switch (code) {
            case 0:
                return null
            case 1:
                return FfiConverterTypeMozAdsRequestOptions.read(dataStream)
            default:
                throw new UniFFIError(`Unexpected code: ${code}`);
        }
    }

    static write(dataStream, value) {
        if (value === null || value === undefined) {
            dataStream.writeUint8(0);
            return;
        }
        dataStream.writeUint8(1);
        FfiConverterTypeMozAdsRequestOptions.write(dataStream, value)
    }

    static computeSize(value) {
        if (value === null || value === undefined) {
            return 1;
        }
        return 1 + FfiConverterTypeMozAdsRequestOptions.computeSize(value)
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterMapStringTypeMozAdsImage extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const map = new Map();
        for (let i = 0; i < len; i++) {
            const key = FfiConverterString.read(dataStream);
            const value = FfiConverterTypeMozAdsImage.read(dataStream);
            map.set(key, value);
        }

        return map;
    }

     static write(dataStream, map) {
        dataStream.writeInt32(map.size);
        for (const [key, value] of map) {
            FfiConverterString.write(dataStream, key);
            FfiConverterTypeMozAdsImage.write(dataStream, value);
        }
    }

    static computeSize(map) {
        // The size of the length
        let size = 4;
        for (const [key, value] of map) {
            size += FfiConverterString.computeSize(key);
            size += FfiConverterTypeMozAdsImage.computeSize(value);
        }
        return size;
    }

    static checkType(map) {
        for (const [key, value] of map) {
            try {
                FfiConverterString.checkType(key);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart("(key)");
                }
                throw e;
            }

            try {
                FfiConverterTypeMozAdsImage.checkType(value);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${key}]`);
                }
                throw e;
            }
        }
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterSequenceTypeMozAdsPlacementRequestWithCount extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const arr = [];
        for (let i = 0; i < len; i++) {
            arr.push(FfiConverterTypeMozAdsPlacementRequestWithCount.read(dataStream));
        }
        return arr;
    }

    static write(dataStream, value) {
        dataStream.writeInt32(value.length);
        value.forEach((innerValue) => {
            FfiConverterTypeMozAdsPlacementRequestWithCount.write(dataStream, innerValue);
        })
    }

    static computeSize(value) {
        // The size of the length
        let size = 4;
        for (const innerValue of value) {
            size += FfiConverterTypeMozAdsPlacementRequestWithCount.computeSize(innerValue);
        }
        return size;
    }

    static checkType(value) {
        if (!Array.isArray(value)) {
            throw new UniFFITypeError(`${value} is not an array`);
        }
        value.forEach((innerValue, idx) => {
            try {
                FfiConverterTypeMozAdsPlacementRequestWithCount.checkType(innerValue);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${idx}]`);
                }
                throw e;
            }
        })
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterSequenceTypeMozAdsSpoc extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const arr = [];
        for (let i = 0; i < len; i++) {
            arr.push(FfiConverterTypeMozAdsSpoc.read(dataStream));
        }
        return arr;
    }

    static write(dataStream, value) {
        dataStream.writeInt32(value.length);
        value.forEach((innerValue) => {
            FfiConverterTypeMozAdsSpoc.write(dataStream, innerValue);
        })
    }

    static computeSize(value) {
        // The size of the length
        let size = 4;
        for (const innerValue of value) {
            size += FfiConverterTypeMozAdsSpoc.computeSize(innerValue);
        }
        return size;
    }

    static checkType(value) {
        if (!Array.isArray(value)) {
            throw new UniFFITypeError(`${value} is not an array`);
        }
        value.forEach((innerValue, idx) => {
            try {
                FfiConverterTypeMozAdsSpoc.checkType(innerValue);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${idx}]`);
                }
                throw e;
            }
        })
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterMapStringSequenceTypeMozAdsSpoc extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const map = new Map();
        for (let i = 0; i < len; i++) {
            const key = FfiConverterString.read(dataStream);
            const value = FfiConverterSequenceTypeMozAdsSpoc.read(dataStream);
            map.set(key, value);
        }

        return map;
    }

     static write(dataStream, map) {
        dataStream.writeInt32(map.size);
        for (const [key, value] of map) {
            FfiConverterString.write(dataStream, key);
            FfiConverterSequenceTypeMozAdsSpoc.write(dataStream, value);
        }
    }

    static computeSize(map) {
        // The size of the length
        let size = 4;
        for (const [key, value] of map) {
            size += FfiConverterString.computeSize(key);
            size += FfiConverterSequenceTypeMozAdsSpoc.computeSize(value);
        }
        return size;
    }

    static checkType(map) {
        for (const [key, value] of map) {
            try {
                FfiConverterString.checkType(key);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart("(key)");
                }
                throw e;
            }

            try {
                FfiConverterSequenceTypeMozAdsSpoc.checkType(value);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${key}]`);
                }
                throw e;
            }
        }
    }
}
// Export the FFIConverter object to make external types work.
export class FfiConverterMapStringTypeMozAdsTile extends FfiConverterArrayBuffer {
    static read(dataStream) {
        const len = dataStream.readInt32();
        const map = new Map();
        for (let i = 0; i < len; i++) {
            const key = FfiConverterString.read(dataStream);
            const value = FfiConverterTypeMozAdsTile.read(dataStream);
            map.set(key, value);
        }

        return map;
    }

     static write(dataStream, map) {
        dataStream.writeInt32(map.size);
        for (const [key, value] of map) {
            FfiConverterString.write(dataStream, key);
            FfiConverterTypeMozAdsTile.write(dataStream, value);
        }
    }

    static computeSize(map) {
        // The size of the length
        let size = 4;
        for (const [key, value] of map) {
            size += FfiConverterString.computeSize(key);
            size += FfiConverterTypeMozAdsTile.computeSize(value);
        }
        return size;
    }

    static checkType(map) {
        for (const [key, value] of map) {
            try {
                FfiConverterString.checkType(key);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart("(key)");
                }
                throw e;
            }

            try {
                FfiConverterTypeMozAdsTile.checkType(value);
            } catch (e) {
                if (e instanceof UniFFITypeError) {
                    e.addItemDescriptionPart(`[${key}]`);
                }
                throw e;
            }
        }
    }
}

/**
 * MozAdsClientInterface
 */
export class MozAdsClientInterface {
    /**
     * clearCache
     */
    async clearCache() {
      throw Error("clearCache not implemented");
    }
    /**
     * recordClick
     * @param {string} clickUrl
     * @param {?MozAdsCallbackOptions} options
     */
    async recordClick(
        clickUrl, 
        options = null) {
      throw Error("recordClick not implemented");
    }
    /**
     * recordImpression
     * @param {string} impressionUrl
     * @param {?MozAdsCallbackOptions} options
     */
    async recordImpression(
        impressionUrl, 
        options = null) {
      throw Error("recordImpression not implemented");
    }
    /**
     * reportAd
     * @param {string} reportUrl
     * @param {MozAdsReportReason[keyof MozAdsReportReason]} reason
     * @param {?MozAdsCallbackOptions} options
     */
    async reportAd(
        reportUrl, 
        reason, 
        options = null) {
      throw Error("reportAd not implemented");
    }
    /**
     * requestImageAds
     * @param {Array.<MozAdsPlacementRequest>} mozAdRequests
     * @param {?MozAdsRequestOptions} options
     * @returns {Promise<object>}}
     */
    async requestImageAds(
        mozAdRequests, 
        options = null) {
      throw Error("requestImageAds not implemented");
    }
    /**
     * requestSpocAds
     * @param {Array.<MozAdsPlacementRequestWithCount>} mozAdRequests
     * @param {?MozAdsRequestOptions} options
     * @returns {Promise<object>}}
     */
    async requestSpocAds(
        mozAdRequests, 
        options = null) {
      throw Error("requestSpocAds not implemented");
    }
    /**
     * requestTileAds
     * @param {Array.<MozAdsPlacementRequest>} mozAdRequests
     * @param {?MozAdsRequestOptions} options
     * @returns {Promise<object>}}
     */
    async requestTileAds(
        mozAdRequests, 
        options = null) {
      throw Error("requestTileAds not implemented");
    }
    /**
     * shutdown
     */
    async shutdown() {
      throw Error("shutdown not implemented");
    }

}

/**
 * MozAdsClient
 */
export class MozAdsClient extends MozAdsClientInterface {
    // Use `init` to instantiate this class.
    // DO NOT USE THIS CONSTRUCTOR DIRECTLY
    constructor(opts) {
        super();
        if (!Object.prototype.hasOwnProperty.call(opts, constructUniffiObject)) {
            throw new UniFFIError("Attempting to construct an int using the JavaScript constructor directly" +
            "Please use a UDL defined constructor, or the init function for the primary constructor")
        }
        if (!(opts[constructUniffiObject] instanceof UniFFIPointer)) {
            throw new UniFFIError("Attempting to create a UniFFI object with a pointer that is not an instance of UniFFIPointer")
        }
        this[uniffiObjectPtr] = opts[constructUniffiObject];
    }

    /**
     * clearCache
     */
    async clearCache() {
       
        const result = await UniFFIScaffolding.callAsyncWrapper(
            1, // uniffi_ads_client_fn_method_mozadsclient_clear_cache
            FfiConverterTypeMozAdsClient.lowerReceiver(this),
        )
        return handleRustResult(
            result,
            (result) => undefined,
            FfiConverterTypeMozAdsClientApiError.lift.bind(FfiConverterTypeMozAdsClientApiError),
        )
    }

    /**
     * recordClick
     * @param {string} clickUrl
     * @param {?MozAdsCallbackOptions} options
     */
    async recordClick(
        clickUrl, 
        options = null) {
       
        FfiConverterString.checkType(clickUrl);
        FfiConverterOptionalTypeMozAdsCallbackOptions.checkType(options);
        const result = await UniFFIScaffolding.callAsyncWrapper(
            2, // uniffi_ads_client_fn_method_mozadsclient_record_click
            FfiConverterTypeMozAdsClient.lowerReceiver(this),
            FfiConverterString.lower(clickUrl),
            FfiConverterOptionalTypeMozAdsCallbackOptions.lower(options),
        )
        return handleRustResult(
            result,
            (result) => undefined,
            FfiConverterTypeMozAdsClientApiError.lift.bind(FfiConverterTypeMozAdsClientApiError),
        )
    }

    /**
     * recordImpression
     * @param {string} impressionUrl
     * @param {?MozAdsCallbackOptions} options
     */
    async recordImpression(
        impressionUrl, 
        options = null) {
       
        FfiConverterString.checkType(impressionUrl);
        FfiConverterOptionalTypeMozAdsCallbackOptions.checkType(options);
        const result = await UniFFIScaffolding.callAsyncWrapper(
            3, // uniffi_ads_client_fn_method_mozadsclient_record_impression
            FfiConverterTypeMozAdsClient.lowerReceiver(this),
            FfiConverterString.lower(impressionUrl),
            FfiConverterOptionalTypeMozAdsCallbackOptions.lower(options),
        )
        return handleRustResult(
            result,
            (result) => undefined,
            FfiConverterTypeMozAdsClientApiError.lift.bind(FfiConverterTypeMozAdsClientApiError),
        )
    }

    /**
     * reportAd
     * @param {string} reportUrl
     * @param {MozAdsReportReason[keyof MozAdsReportReason]} reason
     * @param {?MozAdsCallbackOptions} options
     */
    async reportAd(
        reportUrl, 
        reason, 
        options = null) {
       
        FfiConverterString.checkType(reportUrl);
        FfiConverterTypeMozAdsReportReason.checkType(reason);
        FfiConverterOptionalTypeMozAdsCallbackOptions.checkType(options);
        const result = await UniFFIScaffolding.callAsyncWrapper(
            4, // uniffi_ads_client_fn_method_mozadsclient_report_ad
            FfiConverterTypeMozAdsClient.lowerReceiver(this),
            FfiConverterString.lower(reportUrl),
            FfiConverterTypeMozAdsReportReason.lower(reason),
            FfiConverterOptionalTypeMozAdsCallbackOptions.lower(options),
        )
        return handleRustResult(
            result,
            (result) => undefined,
            FfiConverterTypeMozAdsClientApiError.lift.bind(FfiConverterTypeMozAdsClientApiError),
        )
    }

    /**
     * requestImageAds
     * @param {Array.<MozAdsPlacementRequest>} mozAdRequests
     * @param {?MozAdsRequestOptions} options
     * @returns {Promise<object>}}
     */
    async requestImageAds(
        mozAdRequests, 
        options = null) {
       
        FfiConverterSequenceTypeMozAdsPlacementRequest.checkType(mozAdRequests);
        FfiConverterOptionalTypeMozAdsRequestOptions.checkType(options);
        const result = await UniFFIScaffolding.callAsyncWrapper(
            5, // uniffi_ads_client_fn_method_mozadsclient_request_image_ads
            FfiConverterTypeMozAdsClient.lowerReceiver(this),
            FfiConverterSequenceTypeMozAdsPlacementRequest.lower(mozAdRequests),
            FfiConverterOptionalTypeMozAdsRequestOptions.lower(options),
        )
        return handleRustResult(
            result,
            FfiConverterMapStringTypeMozAdsImage.lift.bind(FfiConverterMapStringTypeMozAdsImage),
            FfiConverterTypeMozAdsClientApiError.lift.bind(FfiConverterTypeMozAdsClientApiError),
        )
    }

    /**
     * requestSpocAds
     * @param {Array.<MozAdsPlacementRequestWithCount>} mozAdRequests
     * @param {?MozAdsRequestOptions} options
     * @returns {Promise<object>}}
     */
    async requestSpocAds(
        mozAdRequests, 
        options = null) {
       
        FfiConverterSequenceTypeMozAdsPlacementRequestWithCount.checkType(mozAdRequests);
        FfiConverterOptionalTypeMozAdsRequestOptions.checkType(options);
        const result = await UniFFIScaffolding.callAsyncWrapper(
            6, // uniffi_ads_client_fn_method_mozadsclient_request_spoc_ads
            FfiConverterTypeMozAdsClient.lowerReceiver(this),
            FfiConverterSequenceTypeMozAdsPlacementRequestWithCount.lower(mozAdRequests),
            FfiConverterOptionalTypeMozAdsRequestOptions.lower(options),
        )
        return handleRustResult(
            result,
            FfiConverterMapStringSequenceTypeMozAdsSpoc.lift.bind(FfiConverterMapStringSequenceTypeMozAdsSpoc),
            FfiConverterTypeMozAdsClientApiError.lift.bind(FfiConverterTypeMozAdsClientApiError),
        )
    }

    /**
     * requestTileAds
     * @param {Array.<MozAdsPlacementRequest>} mozAdRequests
     * @param {?MozAdsRequestOptions} options
     * @returns {Promise<object>}}
     */
    async requestTileAds(
        mozAdRequests, 
        options = null) {
       
        FfiConverterSequenceTypeMozAdsPlacementRequest.checkType(mozAdRequests);
        FfiConverterOptionalTypeMozAdsRequestOptions.checkType(options);
        const result = await UniFFIScaffolding.callAsyncWrapper(
            7, // uniffi_ads_client_fn_method_mozadsclient_request_tile_ads
            FfiConverterTypeMozAdsClient.lowerReceiver(this),
            FfiConverterSequenceTypeMozAdsPlacementRequest.lower(mozAdRequests),
            FfiConverterOptionalTypeMozAdsRequestOptions.lower(options),
        )
        return handleRustResult(
            result,
            FfiConverterMapStringTypeMozAdsTile.lift.bind(FfiConverterMapStringTypeMozAdsTile),
            FfiConverterTypeMozAdsClientApiError.lift.bind(FfiConverterTypeMozAdsClientApiError),
        )
    }

    /**
     * shutdown
     */
    async shutdown() {
       
        const result = await UniFFIScaffolding.callAsyncWrapper(
            8, // uniffi_ads_client_fn_method_mozadsclient_shutdown
            FfiConverterTypeMozAdsClient.lowerReceiver(this),
        )
        return handleRustResult(
            result,
            (result) => undefined,
            FfiConverterTypeMozAdsClientApiError.lift.bind(FfiConverterTypeMozAdsClientApiError),
        )
    }

}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsClient extends FfiConverter {
    static lift(value) {
        const opts = {};
        opts[constructUniffiObject] = value;
        return new MozAdsClient(opts);
    }

    static lower(value) {
        const ptr = value[uniffiObjectPtr];
        if (!(ptr instanceof UniFFIPointer)) {
            throw new UniFFITypeError("Object is not a 'MozAdsClient' instance");
        }
        return ptr;
    }

    static lowerReceiver(value) {
        // This works exactly the same as lower for non-trait interfaces
        return this.lower(value);
    }

    static read(dataStream) {
        return this.lift(dataStream.readPointer(1));
    }

    static write(dataStream, value) {
        dataStream.writePointer(1, this.lower(value));
    }

    static computeSize(value) {
        return 8;
    }
}


/**
 * MozAdsContextIdProvider
 */
export class MozAdsContextIdProvider {
    /**
     * contextId
     * @returns {string}
     */
    contextId() {
      throw Error("contextId not implemented");
    }

}

/**
 * MozAdsContextIdProvider
 */
export class MozAdsContextIdProviderImpl extends MozAdsContextIdProvider {
    // Use `init` to instantiate this class.
    // DO NOT USE THIS CONSTRUCTOR DIRECTLY
    constructor(opts) {
        super();
        if (!Object.prototype.hasOwnProperty.call(opts, constructUniffiObject)) {
            throw new UniFFIError("Attempting to construct an int using the JavaScript constructor directly" +
            "Please use a UDL defined constructor, or the init function for the primary constructor")
        }
        if (!(opts[constructUniffiObject] instanceof UniFFIPointer)) {
            throw new UniFFIError("Attempting to create a UniFFI object with a pointer that is not an instance of UniFFIPointer")
        }
        this[uniffiObjectPtr] = opts[constructUniffiObject];
    }

    /**
     * contextId
     * @returns {string}
     */
    contextId() {
       
        const result = UniFFIScaffolding.callSync(
            9, // uniffi_ads_client_fn_method_mozadscontextidprovider_context_id
            FfiConverterTypeMozAdsContextIdProvider.lowerReceiver(this),
        )
        return handleRustResult(
            result,
            FfiConverterString.lift.bind(FfiConverterString),
            null,
        )
    }

}

// FfiConverter for a trait interface.  This is a hybrid of the FFIConverter regular interfaces and
// for callback interfaces.
//
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsContextIdProvider extends FfiConverter {
    static lift(handle) {
        if (handle instanceof UniFFIPointer) {
          // Rust handle.  Construct an object from it
          const opts = {};
          opts[constructUniffiObject] = handle;
          return new MozAdsContextIdProviderImpl(opts);
        } else {
          // JS handle.  Get the JS object from the callback handler
          return uniffiCallbackHandlerAdsClientMozAdsContextIdProvider.takeCallbackObj(handle)
        }
    }

    static lower(value) {
        const ptr = value[uniffiObjectPtr];
        if (ptr instanceof UniFFIPointer) {
          // Rust-implemented interface, return the ptr.  The C++ code will clone it.
          return ptr;
        } else {
          // JS-implemented interface, store the object in the handle map and return the handle
          if (!(value instanceof MozAdsContextIdProvider)) {
              throw new UniFFITypeError("expected 'MozAdsContextIdProvider' subclass");
          }
          return uniffiCallbackHandlerAdsClientMozAdsContextIdProvider.storeCallbackObj(value)
        }
    }

    // lowerReceiver is used when calling methods on an interface we got from Rust, 
    // it treats value like a regular interface.
    static lowerReceiver(value) {
        const ptr = value[uniffiObjectPtr];
        if (!(ptr instanceof UniFFIPointer)) {
            throw new UniFFITypeError("Object is not a 'MozAdsContextIdProviderImpl' instance");
        }
        return ptr;
    }

    static read(dataStream) {
        return this.lift(dataStream.readHandleOrPointer(2))
    }

    static write(dataStream, value) {
        if (value[uniffiObjectPtr] instanceof UniFFIPointer) {
          // Rust-implemented interface, return the ptr.
          dataStream.writePointer(2, this.lower(value));
        } else {
          dataStream.writeInt64(this.lower(value))
        }
    }

    static computeSize(value) {
        return 8;
    }
}

const uniffiCallbackHandlerAdsClientMozAdsContextIdProvider = new UniFFICallbackHandler(
    "MozAdsContextIdProvider",
    2,
    [
        new UniFFICallbackMethodHandler(
            "contextId",
            [
            ],
            FfiConverterString.lower.bind(FfiConverterString),
            (e) => {
              throw e;
            }
        ),
    ]
);

// Allow the shutdown-related functionality to be tested in the unit tests
UnitTestObjs.uniffiCallbackHandlerAdsClientMozAdsContextIdProvider = uniffiCallbackHandlerAdsClientMozAdsContextIdProvider;

/**
 * MozAdsTelemetry
 */
export class MozAdsTelemetry {
    /**
     * recordBuildCacheError
     * @param {string} label
     * @param {string} value
     */
    recordBuildCacheError(
        label, 
        value) {
      throw Error("recordBuildCacheError not implemented");
    }
    /**
     * recordClientError
     * @param {string} label
     * @param {string} value
     */
    recordClientError(
        label, 
        value) {
      throw Error("recordClientError not implemented");
    }
    /**
     * recordClientOperationTotal
     * @param {string} label
     */
    recordClientOperationTotal(
        label) {
      throw Error("recordClientOperationTotal not implemented");
    }
    /**
     * recordDeserializationError
     * @param {string} label
     * @param {string} value
     */
    recordDeserializationError(
        label, 
        value) {
      throw Error("recordDeserializationError not implemented");
    }
    /**
     * recordHttpCacheOutcome
     * @param {string} label
     * @param {string} value
     */
    recordHttpCacheOutcome(
        label, 
        value) {
      throw Error("recordHttpCacheOutcome not implemented");
    }

}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsTelemetry extends FfiConverter {
    static lower(callbackObj) {
        if (!(callbackObj instanceof MozAdsTelemetry)) {
            throw new UniFFITypeError("expected 'MozAdsTelemetry' subclass");
        }
        return uniffiCallbackHandlerAdsClientMozAdsTelemetry.storeCallbackObj(callbackObj)
    }

    static lift(handleId) {
        return uniffiCallbackHandlerAdsClientMozAdsTelemetry.takeCallbackObj(handleId)
    }

    static read(dataStream) {
        return this.lift(dataStream.readInt64())
    }

    static write(dataStream, callbackObj) {
        dataStream.writeInt64(this.lower(callbackObj))
    }

    static computeSize(callbackObj) {
        return 8;
    }
}
const uniffiCallbackHandlerAdsClientMozAdsTelemetry = new UniFFICallbackHandler(
    "MozAdsTelemetry",
    1,
    [
        new UniFFICallbackMethodHandler(
            "recordBuildCacheError",
            [
                FfiConverterString,
                FfiConverterString,
            ],
            (result) => undefined,
            (e) => {
              throw e;
            }
        ),
        new UniFFICallbackMethodHandler(
            "recordClientError",
            [
                FfiConverterString,
                FfiConverterString,
            ],
            (result) => undefined,
            (e) => {
              throw e;
            }
        ),
        new UniFFICallbackMethodHandler(
            "recordClientOperationTotal",
            [
                FfiConverterString,
            ],
            (result) => undefined,
            (e) => {
              throw e;
            }
        ),
        new UniFFICallbackMethodHandler(
            "recordDeserializationError",
            [
                FfiConverterString,
                FfiConverterString,
            ],
            (result) => undefined,
            (e) => {
              throw e;
            }
        ),
        new UniFFICallbackMethodHandler(
            "recordHttpCacheOutcome",
            [
                FfiConverterString,
                FfiConverterString,
            ],
            (result) => undefined,
            (e) => {
              throw e;
            }
        ),
    ]
);

// Allow the shutdown-related functionality to be tested in the unit tests
UnitTestObjs.uniffiCallbackHandlerAdsClientMozAdsTelemetry = uniffiCallbackHandlerAdsClientMozAdsTelemetry;

/**
 * MozAdsClientBuilderInterface
 */
export class MozAdsClientBuilderInterface {
    /**
     * build
     * @returns {MozAdsClient}
     */
    build() {
      throw Error("build not implemented");
    }
    /**
     * cacheConfig
     * @param {MozAdsCacheConfig} cacheConfig
     * @returns {MozAdsClientBuilder}
     */
    cacheConfig(
        cacheConfig) {
      throw Error("cacheConfig not implemented");
    }
    /**
     * contextIdProvider
     * @param {MozAdsContextIdProvider} provider
     * @returns {MozAdsClientBuilder}
     */
    contextIdProvider(
        provider) {
      throw Error("contextIdProvider not implemented");
    }
    /**
     * environment
     * @param {MozAdsEnvironment[keyof MozAdsEnvironment]} environment
     * @returns {MozAdsClientBuilder}
     */
    environment(
        environment) {
      throw Error("environment not implemented");
    }
    /**
     * telemetry
     * @param {MozAdsTelemetry} telemetry
     * @returns {MozAdsClientBuilder}
     */
    telemetry(
        telemetry) {
      throw Error("telemetry not implemented");
    }

}

/**
 * MozAdsClientBuilder
 */
export class MozAdsClientBuilder extends MozAdsClientBuilderInterface {
    // Use `init` to instantiate this class.
    // DO NOT USE THIS CONSTRUCTOR DIRECTLY
    constructor(opts) {
        super();
        if (!Object.prototype.hasOwnProperty.call(opts, constructUniffiObject)) {
            throw new UniFFIError("Attempting to construct an int using the JavaScript constructor directly" +
            "Please use a UDL defined constructor, or the init function for the primary constructor")
        }
        if (!(opts[constructUniffiObject] instanceof UniFFIPointer)) {
            throw new UniFFIError("Attempting to create a UniFFI object with a pointer that is not an instance of UniFFIPointer")
        }
        this[uniffiObjectPtr] = opts[constructUniffiObject];
    }
    /**
     * init
     * @returns {MozAdsClientBuilder}
     */
    static init() {
       
        const result = UniFFIScaffolding.callSync(
            10, // uniffi_ads_client_fn_constructor_mozadsclientbuilder_new
        )
        return handleRustResult(
            result,
            FfiConverterTypeMozAdsClientBuilder.lift.bind(FfiConverterTypeMozAdsClientBuilder),
            null,
        )
    }

    /**
     * build
     * @returns {MozAdsClient}
     */
    build() {
       
        const result = UniFFIScaffolding.callSync(
            11, // uniffi_ads_client_fn_method_mozadsclientbuilder_build
            FfiConverterTypeMozAdsClientBuilder.lowerReceiver(this),
        )
        return handleRustResult(
            result,
            FfiConverterTypeMozAdsClient.lift.bind(FfiConverterTypeMozAdsClient),
            null,
        )
    }

    /**
     * cacheConfig
     * @param {MozAdsCacheConfig} cacheConfig
     * @returns {MozAdsClientBuilder}
     */
    cacheConfig(
        cacheConfig) {
       
        FfiConverterTypeMozAdsCacheConfig.checkType(cacheConfig);
        const result = UniFFIScaffolding.callSync(
            12, // uniffi_ads_client_fn_method_mozadsclientbuilder_cache_config
            FfiConverterTypeMozAdsClientBuilder.lowerReceiver(this),
            FfiConverterTypeMozAdsCacheConfig.lower(cacheConfig),
        )
        return handleRustResult(
            result,
            FfiConverterTypeMozAdsClientBuilder.lift.bind(FfiConverterTypeMozAdsClientBuilder),
            null,
        )
    }

    /**
     * contextIdProvider
     * @param {MozAdsContextIdProvider} provider
     * @returns {MozAdsClientBuilder}
     */
    contextIdProvider(
        provider) {
       
        FfiConverterTypeMozAdsContextIdProvider.checkType(provider);
        const result = UniFFIScaffolding.callSync(
            13, // uniffi_ads_client_fn_method_mozadsclientbuilder_context_id_provider
            FfiConverterTypeMozAdsClientBuilder.lowerReceiver(this),
            FfiConverterTypeMozAdsContextIdProvider.lower(provider),
        )
        return handleRustResult(
            result,
            FfiConverterTypeMozAdsClientBuilder.lift.bind(FfiConverterTypeMozAdsClientBuilder),
            null,
        )
    }

    /**
     * environment
     * @param {MozAdsEnvironment[keyof MozAdsEnvironment]} environment
     * @returns {MozAdsClientBuilder}
     */
    environment(
        environment) {
       
        FfiConverterTypeMozAdsEnvironment.checkType(environment);
        const result = UniFFIScaffolding.callSync(
            14, // uniffi_ads_client_fn_method_mozadsclientbuilder_environment
            FfiConverterTypeMozAdsClientBuilder.lowerReceiver(this),
            FfiConverterTypeMozAdsEnvironment.lower(environment),
        )
        return handleRustResult(
            result,
            FfiConverterTypeMozAdsClientBuilder.lift.bind(FfiConverterTypeMozAdsClientBuilder),
            null,
        )
    }

    /**
     * telemetry
     * @param {MozAdsTelemetry} telemetry
     * @returns {MozAdsClientBuilder}
     */
    telemetry(
        telemetry) {
       
        FfiConverterTypeMozAdsTelemetry.checkType(telemetry);
        const result = UniFFIScaffolding.callSync(
            15, // uniffi_ads_client_fn_method_mozadsclientbuilder_telemetry
            FfiConverterTypeMozAdsClientBuilder.lowerReceiver(this),
            FfiConverterTypeMozAdsTelemetry.lower(telemetry),
        )
        return handleRustResult(
            result,
            FfiConverterTypeMozAdsClientBuilder.lift.bind(FfiConverterTypeMozAdsClientBuilder),
            null,
        )
    }

}

// Export the FFIConverter object to make external types work.
export class FfiConverterTypeMozAdsClientBuilder extends FfiConverter {
    static lift(value) {
        const opts = {};
        opts[constructUniffiObject] = value;
        return new MozAdsClientBuilder(opts);
    }

    static lower(value) {
        const ptr = value[uniffiObjectPtr];
        if (!(ptr instanceof UniFFIPointer)) {
            throw new UniFFITypeError("Object is not a 'MozAdsClientBuilder' instance");
        }
        return ptr;
    }

    static lowerReceiver(value) {
        // This works exactly the same as lower for non-trait interfaces
        return this.lower(value);
    }

    static read(dataStream) {
        return this.lift(dataStream.readPointer(3));
    }

    static write(dataStream, value) {
        dataStream.writePointer(3, this.lower(value));
    }

    static computeSize(value) {
        return 8;
    }
}



