use dom_struct::dom_struct;
use js::context::JSContext;
use js::rust::HandleObject;
use malloc_size_of_derive::MallocSizeOf;
use script_bindings::DomTypes;
use script_bindings::codegen::GenericBindings::WebGPUBinding::{
GPUValidationErrorMethods, GPUValidationErrorWrap,
};
use script_bindings::conversions::DerivedFrom;
use script_bindings::inheritance::Castable;
use script_bindings::reflector::reflect_dom_object_with_proto_and_wrap;
use crate::JSTraceable;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::gpuerror::GPUError;
use crate::traits::Equivalence;
#[dom_struct]
pub struct GPUValidationError<D: DomTypes> {
gpu_error: GPUError<D>,
}
impl<D> GPUValidationError<D>
where
D: Equivalence,
D::GPUError: Castable,
D::GPUValidationError: DerivedFrom<GPUError<D>>,
D::GPUOutOfMemoryError: DerivedFrom<GPUError<D>>,
D::GPUInternalError: DerivedFrom<GPUError<D>>,
{
fn new_inherited(message: DOMString) -> Self {
Self {
gpu_error: GPUError::new_inherited(message),
}
}
pub(crate) fn new_with_proto(
cx: &mut JSContext,
global: &D::GlobalScope,
proto: Option<HandleObject>,
message: DOMString,
) -> DomRoot<Self> {
reflect_dom_object_with_proto_and_wrap::<D, _, _>(
cx,
Box::new(Self::new_inherited(message)),
global,
proto,
GPUValidationErrorWrap::<D>,
)
}
}
impl<D> GPUValidationErrorMethods<D> for GPUValidationError<D>
where
D: Equivalence,
D::GPUError: Castable,
D::GPUValidationError: DerivedFrom<GPUError<D>>,
D::GPUOutOfMemoryError: DerivedFrom<GPUError<D>>,
D::GPUInternalError: DerivedFrom<GPUError<D>>,
{
fn Constructor(
cx: &mut js::context::JSContext,
global: &D::GlobalScope,
proto: Option<HandleObject>,
message: DOMString,
) -> DomRoot<Self> {
Self::new_with_proto(cx, global, proto, message)
}
}