Files
tubestation/toolkit/components/uniffi-js/UniFFICallbacks.h
Jan-Erik Rediger 6cf00b2538 Bug 1840044 - Update to Glean 53.1.0, UniFFI 0.24.1 and latest application-services. r=TravisLong,nika,markh,supply-chain-reviewers
Update:
  - Glean to v53.1.0
  - UniFFI to v0.24.1
  - application-services to a recent nightly that uses the above
    versions

- Updated `rusqlite` in toolkit/library/rust/shared/Cargo.toml
- Updated `uniffi-bindgen-gecko-js` to work with the new UniFFI.  Also
  updated it's askama version.
- Vetted new cargo dependencies

Ran `mach uniffi generate` to regenerate the code.

Differential Revision: https://phabricator.services.mozilla.com/D181872
2023-07-26 15:34:27 +00:00

76 lines
2.4 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_UniFFICallbacks_h
#define mozilla_UniFFICallbacks_h
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/UniFFIRust.h"
#include "mozilla/dom/UniFFIScaffolding.h"
namespace mozilla::uniffi {
/**
* UniFFI-generated scaffolding function to initialize a callback interface
*
* The Rust code expests us to pass it a ForeignCallback entrypoint for each
* callback interface.
*/
typedef void (*CallbackInitFunc)(ForeignCallback, RustCallStatus*);
/**
* All the information needed to handle a callback interface.
*
* The generated code includes a function that maps interface ids to one of
* these structs
*/
struct CallbackInterfaceInfo {
// Human-friendly name
const char* mName;
// JS handler
StaticRefPtr<dom::UniFFICallbackHandler>* mHandler;
// Handler function, defined in the generated C++ code
ForeignCallback mForeignCallback;
// Init function, defined in the generated Rust scaffolding. mForeignCallback
// should be passed to this.
CallbackInitFunc mInitForeignCallback;
};
Maybe<CallbackInterfaceInfo> UniFFIGetCallbackInterfaceInfo(
uint64_t aInterfaceId);
#ifdef MOZ_UNIFFI_FIXTURES
Maybe<CallbackInterfaceInfo> UniFFIFixturesGetCallbackInterfaceInfo(
uint64_t aInterfaceId);
#endif
/**
* Register the JS handler for a callback interface
*/
void RegisterCallbackHandler(uint64_t aInterfaceId,
dom::UniFFICallbackHandler& aCallbackHandler,
ErrorResult& aError);
/**
* Deregister the JS handler for a callback interface
*/
void DeregisterCallbackHandler(uint64_t aInterfaceId, ErrorResult& aError);
/**
* Queue a UniFFI callback interface function to run at some point
*
* This function is for fire-and-forget callbacks where the caller doesn't care
* about the return value and doesn't want to wait for the call to finish. A
* good use case for this is logging.
*/
MOZ_CAN_RUN_SCRIPT
void QueueCallback(size_t aInterfaceId, uint64_t aHandle, uint32_t aMethod,
const uint8_t* aArgsData, int32_t aArgsLen);
} // namespace mozilla::uniffi
#endif // mozilla_UniFFICallbacks_h