script_webgpu/
gpuvalidationerror.rs1use dom_struct::dom_struct;
6use js::context::JSContext;
7use js::rust::HandleObject;
8use malloc_size_of_derive::MallocSizeOf;
9use script_bindings::DomTypes;
10use script_bindings::codegen::GenericBindings::WebGPUBinding::{
11 GPUValidationErrorMethods, GPUValidationErrorWrap,
12};
13use script_bindings::conversions::DerivedFrom;
14use script_bindings::inheritance::Castable;
15use script_bindings::reflector::reflect_dom_object_with_proto_and_wrap;
16
17use crate::JSTraceable;
18use crate::dom::bindings::root::DomRoot;
19use crate::dom::bindings::str::DOMString;
20use crate::gpuerror::GPUError;
21use crate::traits::Equivalence;
22
23#[dom_struct]
24pub struct GPUValidationError<D: DomTypes> {
25 gpu_error: GPUError<D>,
26}
27
28impl<D> GPUValidationError<D>
29where
30 D: Equivalence,
31 D::GPUError: Castable,
32 D::GPUValidationError: DerivedFrom<GPUError<D>>,
33 D::GPUOutOfMemoryError: DerivedFrom<GPUError<D>>,
34 D::GPUInternalError: DerivedFrom<GPUError<D>>,
35{
36 fn new_inherited(message: DOMString) -> Self {
37 Self {
38 gpu_error: GPUError::new_inherited(message),
39 }
40 }
41
42 pub(crate) fn new_with_proto(
43 cx: &mut JSContext,
44 global: &D::GlobalScope,
45 proto: Option<HandleObject>,
46 message: DOMString,
47 ) -> DomRoot<Self> {
48 reflect_dom_object_with_proto_and_wrap::<D, _, _>(
49 Box::new(Self::new_inherited(message)),
50 global,
51 proto,
52 cx,
53 GPUValidationErrorWrap::<D>,
54 )
55 }
56}
57
58impl<D> GPUValidationErrorMethods<D> for GPUValidationError<D>
59where
60 D: Equivalence,
61 D::GPUError: Castable,
62 D::GPUValidationError: DerivedFrom<GPUError<D>>,
63 D::GPUOutOfMemoryError: DerivedFrom<GPUError<D>>,
64 D::GPUInternalError: DerivedFrom<GPUError<D>>,
65{
66 fn Constructor(
68 cx: &mut js::context::JSContext,
69 global: &D::GlobalScope,
70 proto: Option<HandleObject>,
71 message: DOMString,
72 ) -> DomRoot<Self> {
73 Self::new_with_proto(cx, global, proto, message)
74 }
75}