Skip to main content

script_webgpu/
promise.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use std::rc::Rc;
6use std::sync::Arc;
7
8use script_bindings::DomTypes;
9use servo_base::generic_channel::GenericCallback;
10use webgpu_traits::WebGPUDeviceResponse;
11
12use crate::gpuadapter::GPUAdapter;
13use crate::identityhub::IdentityHub;
14
15/// The main trait for creating and using promises in script_webgpu.
16pub trait WebGPUPromiseTrait<D: DomTypes> {
17    fn callback_promise(
18        self: &Rc<Self>,
19        d: &GPUAdapter<D>,
20    ) -> GenericCallback<WebGPUDeviceResponse>;
21}
22
23pub trait WebGPUGlobalTrait {
24    fn global_wgpu_id_hub(&self) -> Arc<IdentityHub>;
25}