wasm_bindgen/rt/
marker.rs1#[cfg_attr(
3 wbg_diagnostic,
4 diagnostic::on_unimplemented(
5 message = "JavaScript constructors are not supported for `{Self}`",
6 label = "this function cannot be the constructor of `{Self}`",
7 note = "`#[wasm_bindgen(constructor)]` is only supported for `struct`s and cannot be used for `enum`s.",
8 note = "Consider removing the `constructor` option and using a regular static method instead."
9 )
10)]
11pub trait SupportsConstructor {}
12pub struct CheckSupportsConstructor<T: SupportsConstructor>(T);
13
14#[cfg_attr(
17 wbg_diagnostic,
18 diagnostic::on_unimplemented(
19 message = "JavaScript instance getters and setters are not supported for `{Self}`",
20 label = "this method cannot be a getter or setter for `{Self}`",
21 note = "`#[wasm_bindgen(getter)]` and `#[wasm_bindgen(setter)]` are only supported for `struct`s and cannot be used for `enum`s.",
22 )
23)]
24pub trait SupportsInstanceProperty {}
25pub struct CheckSupportsInstanceProperty<T: SupportsInstanceProperty>(T);
26
27#[cfg_attr(
30 wbg_diagnostic,
31 diagnostic::on_unimplemented(
32 message = "JavaScript static getters and setters are not supported for `{Self}`",
33 label = "this static function cannot be a static getter or setter on `{Self}`",
34 note = "`#[wasm_bindgen(getter)]` and `#[wasm_bindgen(setter)]` are only supported for `struct`s and cannot be used for `enum`s.",
35 )
36)]
37pub trait SupportsStaticProperty {}
38pub struct CheckSupportsStaticProperty<T: SupportsStaticProperty>(T);
39
40#[cfg(all(
41 feature = "std",
42 all(target_family = "wasm", not(target_os = "wasi")),
43 panic = "unwind"
44))]
45use core::panic::UnwindSafe;
46
47pub trait JsStringLikeSealed {}
50
51pub trait MaybeUnwindSafe {}
53
54#[cfg(all(
55 feature = "std",
56 all(target_family = "wasm", not(target_os = "wasi")),
57 panic = "unwind"
58))]
59impl<T: UnwindSafe + ?Sized> MaybeUnwindSafe for T {}
60
61#[cfg(not(all(
62 feature = "std",
63 all(target_family = "wasm", not(target_os = "wasi")),
64 panic = "unwind"
65)))]
66impl<T: ?Sized> MaybeUnwindSafe for T {}
67
68pub unsafe trait ErasableGeneric {
83 type Repr: 'static;
85}
86
87unsafe impl<T: ErasableGeneric> ErasableGeneric for &mut T {
88 type Repr = &'static mut T::Repr;
89}
90
91unsafe impl<T: ErasableGeneric> ErasableGeneric for &T {
92 type Repr = &'static T::Repr;
93}
94
95#[cfg_attr(
100 wbg_diagnostic,
101 diagnostic::on_unimplemented(
102 message = "Unable to call function, since the concrete generic argument or return value cannot be type-erased into the expected generic repr type for the function",
103 label = "passed concrete generic type does not match the expected generic repr type",
104 note = "Make sure that all erasable generic parameters satisfy the trait bound `ErasableGeneric` with the correct repr. Wasm Bindgen generic parameters and return values for functions are defined to work for specific type-erasable generic repr types only.",
105 )
106)]
107pub trait ErasableGenericOwn<ConcreteTarget>: ErasableGeneric {}
108
109impl<T, ConcreteTarget> ErasableGenericOwn<ConcreteTarget> for T
110where
111 ConcreteTarget: ErasableGeneric,
112 T: ErasableGeneric<Repr = <ConcreteTarget as ErasableGeneric>::Repr>,
113{
114}
115
116#[cfg_attr(
121 wbg_diagnostic,
122 diagnostic::on_unimplemented(
123 message = "Unable to call this function, since the concrete generic argument or return value cannot be type-erased into the expected generic repr type for the function",
124 label = "concrete generic type does not match the expected generic repr type",
125 note = "Make sure that all erasable generic parameters satisfy the trait bound `ErasableGeneric` with the correct repr. Wasm Bindgen generic parameters and return values for functions are defined to work for specific type-erasable generic repr types only.",
126 )
127)]
128pub trait ErasableGenericBorrow<Target: ?Sized> {}
129
130impl<'a, T: ?Sized + 'a, ConcreteTarget: ?Sized + 'static> ErasableGenericBorrow<ConcreteTarget>
131 for T
132where
133 &'static ConcreteTarget: ErasableGeneric,
134 &'a T: ErasableGeneric<Repr = <&'static ConcreteTarget as ErasableGeneric>::Repr>,
135{
136}
137
138#[cfg_attr(
143 wbg_diagnostic,
144 diagnostic::on_unimplemented(
145 message = "Unable to call this function, since the concrete generic argument or return value cannot be type-erased into the expected generic repr type for the function",
146 label = "concrete generic type does not match the expected generic repr type",
147 note = "Make sure that all erasable generic parameters satisfy the trait bound `ErasableGeneric` with the correct repr. Wasm Bindgen generic parameters and return values for functions are defined to work for specific type-erasable generic repr types only.",
148 )
149)]
150pub trait ErasableGenericBorrowMut<Target: ?Sized> {}
151
152impl<'a, T: ?Sized + 'a, ConcreteTarget: ?Sized + 'static> ErasableGenericBorrowMut<ConcreteTarget>
153 for T
154where
155 &'static mut ConcreteTarget: ErasableGeneric,
156 &'a mut T: ErasableGeneric<Repr = <&'static mut ConcreteTarget as ErasableGeneric>::Repr>,
157{
158}