//
// DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/toolkit/components/ml/nsIMLModelHub.idl
//
/// `interface nsIMLModelDownloadProgressCallback : nsISupports`
///
// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.
#[repr(C)]
pub struct nsIMLModelDownloadProgressCallback {
vtable: &'static nsIMLModelDownloadProgressCallbackVTable,
/// This field is a phantomdata to ensure that the VTable type and any
/// struct containing it is not safe to send across threads by default, as
/// XPCOM is generally not threadsafe.
///
/// If this type is marked as [rust_sync], there will be explicit `Send` and
/// `Sync` implementations on this type, which will override the inherited
/// negative impls from `Rc`.
__nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
// Make the rust compiler aware that there might be interior mutability
// in what actually implements the interface. This works around UB
// introduced by https://github.com/llvm/llvm-project/commit/01859da84bad95fd51d6a03b08b60c660e642a4f
// that a rust lint would make blatantly obvious, but doesn't exist.
// This prevents optimizations, but those optimizations weren't available
// before rustc switched to LLVM 16, and they now cause problems because
// of the UB.
// Until there's a lint available to find all our UB, it's simpler to
// avoid the UB in the first place, at the cost of preventing optimizations
// in places that don't cause UB. But again, those optimizations weren't
// available before.
__maybe_interior_mutability: ::std::cell::UnsafeCell<[u8; 0]>,
}
// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsIMLModelDownloadProgressCallback.
unsafe impl XpCom for nsIMLModelDownloadProgressCallback {
const IID: nsIID = nsID(0xe7f880f7, 0xee8a, 0x445e,
[0x87, 0xa8, 0x56, 0x57, 0xd8, 0xc4, 0x7b, 0xd9]);
}
// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsIMLModelDownloadProgressCallback {
#[inline]
unsafe fn addref(&self) {
self.AddRef();
}
#[inline]
unsafe fn release(&self) {
self.Release();
}
}
// This trait is implemented on all types which can be coerced to from nsIMLModelDownloadProgressCallback.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsIMLModelDownloadProgressCallbackCoerce {
/// Cheaply cast a value of this type from a `nsIMLModelDownloadProgressCallback`.
fn coerce_from(v: &nsIMLModelDownloadProgressCallback) -> &Self;
}
// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsIMLModelDownloadProgressCallbackCoerce for nsIMLModelDownloadProgressCallback {
#[inline]
fn coerce_from(v: &nsIMLModelDownloadProgressCallback) -> &Self {
v
}
}
impl nsIMLModelDownloadProgressCallback {
/// Cast this `nsIMLModelDownloadProgressCallback` to one of its base interfaces.
#[inline]
pub fn coerce<T: nsIMLModelDownloadProgressCallbackCoerce>(&self) -> &T {
T::coerce_from(self)
}
}
// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsIMLModelDownloadProgressCallback {
type Target = nsISupports;
#[inline]
fn deref(&self) -> &nsISupports {
unsafe {
::std::mem::transmute(self)
}
}
}
// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsIMLModelDownloadProgressCallbackCoerce for T {
#[inline]
fn coerce_from(v: &nsIMLModelDownloadProgressCallback) -> &Self {
T::coerce_from(v)
}
}
// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsIMLModelDownloadProgressCallback
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsIMLModelDownloadProgressCallbackVTable {
/// We need to include the members from the base interface's vtable at the start
/// of the VTable definition.
pub __base: nsISupportsVTable,
/* void onProgress (in long aProgress, in long long aCurrentLoaded, in long long aTotalLoaded, in long long aTotal); */
pub OnProgress: unsafe extern "system" fn (this: *const nsIMLModelDownloadProgressCallback, aProgress: i32, aCurrentLoaded: i64, aTotalLoaded: i64, aTotal: i64) -> ::nserror::nsresult,
}
// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsIMLModelDownloadProgressCallback {
/// ```text
/// /**
/// * Callback interface for receiving progress updates during model download
/// */
/// /**
/// * Called to report download progress
/// *
/// * @param aProgress - Progress as a percentage (0-100)
/// * @param aCurrentLoaded - Bytes loaded for current file
/// * @param aTotalLoaded - Total bytes loaded across all files
/// * @param aTotal - Total bytes to download (may be 0 if unknown)
/// */
/// ```
///
/// `void onProgress (in long aProgress, in long long aCurrentLoaded, in long long aTotalLoaded, in long long aTotal);`
#[inline]
pub unsafe fn OnProgress(&self, aProgress: i32, aCurrentLoaded: i64, aTotalLoaded: i64, aTotal: i64) -> ::nserror::nsresult {
((*self.vtable).OnProgress)(self, aProgress, aCurrentLoaded, aTotalLoaded, aTotal)
}
}
/// `interface nsIMLModelDownloadCompletionCallback : nsISupports`
///
// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.
#[repr(C)]
pub struct nsIMLModelDownloadCompletionCallback {
vtable: &'static nsIMLModelDownloadCompletionCallbackVTable,
/// This field is a phantomdata to ensure that the VTable type and any
/// struct containing it is not safe to send across threads by default, as
/// XPCOM is generally not threadsafe.
///
/// If this type is marked as [rust_sync], there will be explicit `Send` and
/// `Sync` implementations on this type, which will override the inherited
/// negative impls from `Rc`.
__nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
// Make the rust compiler aware that there might be interior mutability
// in what actually implements the interface. This works around UB
// introduced by https://github.com/llvm/llvm-project/commit/01859da84bad95fd51d6a03b08b60c660e642a4f
// that a rust lint would make blatantly obvious, but doesn't exist.
// This prevents optimizations, but those optimizations weren't available
// before rustc switched to LLVM 16, and they now cause problems because
// of the UB.
// Until there's a lint available to find all our UB, it's simpler to
// avoid the UB in the first place, at the cost of preventing optimizations
// in places that don't cause UB. But again, those optimizations weren't
// available before.
__maybe_interior_mutability: ::std::cell::UnsafeCell<[u8; 0]>,
}
// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsIMLModelDownloadCompletionCallback.
unsafe impl XpCom for nsIMLModelDownloadCompletionCallback {
const IID: nsIID = nsID(0x9c0d1e2f, 0x5678, 0x4321,
[0x90, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde]);
}
// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsIMLModelDownloadCompletionCallback {
#[inline]
unsafe fn addref(&self) {
self.AddRef();
}
#[inline]
unsafe fn release(&self) {
self.Release();
}
}
// This trait is implemented on all types which can be coerced to from nsIMLModelDownloadCompletionCallback.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsIMLModelDownloadCompletionCallbackCoerce {
/// Cheaply cast a value of this type from a `nsIMLModelDownloadCompletionCallback`.
fn coerce_from(v: &nsIMLModelDownloadCompletionCallback) -> &Self;
}
// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsIMLModelDownloadCompletionCallbackCoerce for nsIMLModelDownloadCompletionCallback {
#[inline]
fn coerce_from(v: &nsIMLModelDownloadCompletionCallback) -> &Self {
v
}
}
impl nsIMLModelDownloadCompletionCallback {
/// Cast this `nsIMLModelDownloadCompletionCallback` to one of its base interfaces.
#[inline]
pub fn coerce<T: nsIMLModelDownloadCompletionCallbackCoerce>(&self) -> &T {
T::coerce_from(self)
}
}
// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsIMLModelDownloadCompletionCallback {
type Target = nsISupports;
#[inline]
fn deref(&self) -> &nsISupports {
unsafe {
::std::mem::transmute(self)
}
}
}
// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsIMLModelDownloadCompletionCallbackCoerce for T {
#[inline]
fn coerce_from(v: &nsIMLModelDownloadCompletionCallback) -> &Self {
T::coerce_from(v)
}
}
// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsIMLModelDownloadCompletionCallback
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsIMLModelDownloadCompletionCallbackVTable {
/// We need to include the members from the base interface's vtable at the start
/// of the VTable definition.
pub __base: nsISupportsVTable,
/* void onSuccess (in AString aModel, in AString aRevision); */
pub OnSuccess: unsafe extern "system" fn (this: *const nsIMLModelDownloadCompletionCallback, aModel: *const ::nsstring::nsAString, aRevision: *const ::nsstring::nsAString) -> ::nserror::nsresult,
/* void onError (in AString aError); */
pub OnError: unsafe extern "system" fn (this: *const nsIMLModelDownloadCompletionCallback, aError: *const ::nsstring::nsAString) -> ::nserror::nsresult,
}
// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsIMLModelDownloadCompletionCallback {
/// ```text
/// /**
/// * Callback interface for receiving completion notification after model download
/// */
/// /**
/// * Called when model download completes successfully
/// *
/// * @param aModel - The model name
/// * @param aRevision - The model revision
/// */
/// ```
///
/// `void onSuccess (in AString aModel, in AString aRevision);`
#[inline]
pub unsafe fn OnSuccess(&self, aModel: *const ::nsstring::nsAString, aRevision: *const ::nsstring::nsAString) -> ::nserror::nsresult {
((*self.vtable).OnSuccess)(self, aModel, aRevision)
}
/// ```text
/// /**
/// * Called when model download fails
/// *
/// * @param aError - Error message describing the failure
/// */
/// ```
///
/// `void onError (in AString aError);`
#[inline]
pub unsafe fn OnError(&self, aError: *const ::nsstring::nsAString) -> ::nserror::nsresult {
((*self.vtable).OnError)(self, aError)
}
}
/// `interface nsIMLModelHub : nsISupports`
///
/// ```text
/// /**
/// * A service for checking model availability and downloading models
/// * from the ML ModelHub for use by C++ components like SpeechRecognition
/// */
/// ```
///
// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.
#[repr(C)]
pub struct nsIMLModelHub {
vtable: &'static nsIMLModelHubVTable,
/// This field is a phantomdata to ensure that the VTable type and any
/// struct containing it is not safe to send across threads by default, as
/// XPCOM is generally not threadsafe.
///
/// If this type is marked as [rust_sync], there will be explicit `Send` and
/// `Sync` implementations on this type, which will override the inherited
/// negative impls from `Rc`.
__nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
// Make the rust compiler aware that there might be interior mutability
// in what actually implements the interface. This works around UB
// introduced by https://github.com/llvm/llvm-project/commit/01859da84bad95fd51d6a03b08b60c660e642a4f
// that a rust lint would make blatantly obvious, but doesn't exist.
// This prevents optimizations, but those optimizations weren't available
// before rustc switched to LLVM 16, and they now cause problems because
// of the UB.
// Until there's a lint available to find all our UB, it's simpler to
// avoid the UB in the first place, at the cost of preventing optimizations
// in places that don't cause UB. But again, those optimizations weren't
// available before.
__maybe_interior_mutability: ::std::cell::UnsafeCell<[u8; 0]>,
}
// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsIMLModelHub.
unsafe impl XpCom for nsIMLModelHub {
const IID: nsIID = nsID(0xe381b167, 0xcb68, 0x429c,
[0x9d, 0x57, 0x35, 0xac, 0xf9, 0x05, 0x45, 0x05]);
}
// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsIMLModelHub {
#[inline]
unsafe fn addref(&self) {
self.AddRef();
}
#[inline]
unsafe fn release(&self) {
self.Release();
}
}
// This trait is implemented on all types which can be coerced to from nsIMLModelHub.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsIMLModelHubCoerce {
/// Cheaply cast a value of this type from a `nsIMLModelHub`.
fn coerce_from(v: &nsIMLModelHub) -> &Self;
}
// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsIMLModelHubCoerce for nsIMLModelHub {
#[inline]
fn coerce_from(v: &nsIMLModelHub) -> &Self {
v
}
}
impl nsIMLModelHub {
/// Cast this `nsIMLModelHub` to one of its base interfaces.
#[inline]
pub fn coerce<T: nsIMLModelHubCoerce>(&self) -> &T {
T::coerce_from(self)
}
}
// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsIMLModelHub {
type Target = nsISupports;
#[inline]
fn deref(&self) -> &nsISupports {
unsafe {
::std::mem::transmute(self)
}
}
}
// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsIMLModelHubCoerce for T {
#[inline]
fn coerce_from(v: &nsIMLModelHub) -> &Self {
T::coerce_from(v)
}
}
// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsIMLModelHub
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsIMLModelHubVTable {
/// We need to include the members from the base interface's vtable at the start
/// of the VTable definition.
pub __base: nsISupportsVTable,
/* Promise isModelAvailable (in AUTF8String aEngineId, in AUTF8String aModel, in AUTF8String aRevision, in AUTF8String aFilename); */
/// Unable to generate binding because `special type promise unsupported`
pub IsModelAvailable: *const ::libc::c_void,
/* Promise isModelInstalled (in AUTF8String aEngineId, in AUTF8String aModel, in AUTF8String aRevision, in AUTF8String aFilename); */
/// Unable to generate binding because `special type promise unsupported`
pub IsModelInstalled: *const ::libc::c_void,
/* AString downloadModel (in AUTF8String aEngineId, in AUTF8String aTaskName, in AUTF8String aModel, in AUTF8String aRevision, in Array<AUTF8String> aFiles, in AString aProgressToken, in nsIMLModelDownloadProgressCallback aProgressCallback, in nsIMLModelDownloadCompletionCallback aCompletionCallback); */
pub DownloadModel: unsafe extern "system" fn (this: *const nsIMLModelHub, aEngineId: *const ::nsstring::nsACString, aTaskName: *const ::nsstring::nsACString, aModel: *const ::nsstring::nsACString, aRevision: *const ::nsstring::nsACString, aFiles: *const thin_vec::ThinVec<::nsstring::nsCString>, aProgressToken: *const ::nsstring::nsAString, aProgressCallback: *const nsIMLModelDownloadProgressCallback, aCompletionCallback: *const nsIMLModelDownloadCompletionCallback, _retval: *mut ::nsstring::nsAString) -> ::nserror::nsresult,
/* Promise getModelBlob (in AUTF8String aEngineId, in AUTF8String aTaskName, in AUTF8String aModel, in AUTF8String aRevision, in AUTF8String aFile); */
/// Unable to generate binding because `special type promise unsupported`
pub GetModelBlob: *const ::libc::c_void,
}
// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsIMLModelHub {
/// ```text
/// /**
/// * Check if a model is available (either cached or downloadable)
/// *
/// * @param aEngineId - The engine ID to use
/// * @param aModel - The model name (organization/name)
/// * @param aRevision - The model revision
/// * @param aFilename - The file name to check
/// * @returns Promise that resolves to true if model is available, false otherwise
/// */
/// ```
///
/// `Promise isModelAvailable (in AUTF8String aEngineId, in AUTF8String aModel, in AUTF8String aRevision, in AUTF8String aFilename);`
const _IsModelAvailable: () = ();
/// ```text
/// /**
/// * Check if a model is already downloaded to the local cache. Unlike
/// * isModelAvailable, which also reports models that are merely downloadable
/// * from the hub, this only reports true for a model that needs no download.
/// *
/// * @param aEngineId - The engine ID to use
/// * @param aModel - The model name (organization/name)
/// * @param aRevision - The model revision
/// * @param aFilename - The file name to check
/// * @returns Promise that resolves to true if the model is already installed
/// */
/// ```
///
/// `Promise isModelInstalled (in AUTF8String aEngineId, in AUTF8String aModel, in AUTF8String aRevision, in AUTF8String aFilename);`
const _IsModelInstalled: () = ();
/// ```text
/// /**
/// * Download a model with progress and completion callbacks
/// *
/// * @param aEngineId - The engine ID to use
/// * @param aTaskName - Name of the task (e.g., "speech-recognition")
/// * @param aModel - The model name (organization/name)
/// * @param aRevision - The model revision
/// * @param aFiles - Array of file names to download
/// * @param aProgressToken - Non-empty id tagging this download's progress
/// * notifications
/// * @param aProgressCallback - Optional callback for progress updates
/// * @param aCompletionCallback - Callback for completion notification
/// * @returns sessionId for tracking this download
/// */
/// ```
///
/// `AString downloadModel (in AUTF8String aEngineId, in AUTF8String aTaskName, in AUTF8String aModel, in AUTF8String aRevision, in Array<AUTF8String> aFiles, in AString aProgressToken, in nsIMLModelDownloadProgressCallback aProgressCallback, in nsIMLModelDownloadCompletionCallback aCompletionCallback);`
#[inline]
pub unsafe fn DownloadModel(&self, aEngineId: *const ::nsstring::nsACString, aTaskName: *const ::nsstring::nsACString, aModel: *const ::nsstring::nsACString, aRevision: *const ::nsstring::nsACString, aFiles: *const thin_vec::ThinVec<::nsstring::nsCString>, aProgressToken: *const ::nsstring::nsAString, aProgressCallback: *const nsIMLModelDownloadProgressCallback, aCompletionCallback: *const nsIMLModelDownloadCompletionCallback, _retval: *mut ::nsstring::nsAString) -> ::nserror::nsresult {
((*self.vtable).DownloadModel)(self, aEngineId, aTaskName, aModel, aRevision, aFiles, aProgressToken, aProgressCallback, aCompletionCallback, _retval)
}
/// ```text
/// /**
/// * Get a blob for a downloaded model file
/// *
/// * @param aEngineId - The engine ID to use
/// * @param aTaskName - Name of the task (e.g., "speech-recognition")
/// * @param aModel - The model name (organization/name)
/// * @param aRevision - The model revision
/// * @param aFile - The file name
/// * @returns Promise that resolves to a Blob for the model file
/// */
/// ```
///
/// `Promise getModelBlob (in AUTF8String aEngineId, in AUTF8String aTaskName, in AUTF8String aModel, in AUTF8String aRevision, in AUTF8String aFile);`
const _GetModelBlob: () = ();
}