1#[repr(transparent)]
2pub struct ExternAny {
3 inner: wasm_bindgen::JsValue
4}
5
6impl ExternAny {
7 const NULL: Self = Self::from_js_value(wasm_bindgen::JsValue::NULL);
8 const UNDEFINED: Self = Self::from_js_value(wasm_bindgen::JsValue::UNDEFINED);
9 const TRUE: Self = Self::from_js_value(wasm_bindgen::JsValue::TRUE);
10 const FALSE: Self = Self::from_js_value(wasm_bindgen::JsValue::FALSE);
11
12 #[inline]
13 pub const fn from_js_value(value: wasm_bindgen::JsValue) -> Self {
14 Self { inner: value }
15 }
16
17 #[inline]
18 pub const fn from_js_value_ref(value: &wasm_bindgen::JsValue) -> &Self {
19 unsafe { &*(&raw const *value).cast() }
21 }
22
23 #[inline]
24 pub const fn as_js_value(&self) -> &wasm_bindgen::JsValue {
25 &self.inner
26 }
27
28 #[inline]
29 pub fn into_js_value(self) -> wasm_bindgen::JsValue {
30 self.inner
31 }
32
33 #[inline]
34 pub const fn new_null() -> Self {
35 Self::NULL
36 }
37
38 #[inline]
39 pub const fn new_undefined() -> Self {
40 Self::UNDEFINED
41 }
42
43 #[inline]
44 pub const fn new_true() -> Self {
45 Self::TRUE
46 }
47
48 #[inline]
49 pub const fn new_false() -> Self {
50 Self::FALSE
51 }
52
53 #[inline]
54 pub fn new_symbol(desc: Option<&str>) -> Self {
55 Self::from_js_value(wasm_bindgen::JsValue::symbol(desc))
56 }
57
58 #[expect(clippy::should_implement_trait, reason = "yeag")]
59 #[inline]
60 pub fn from_str(value: &str) -> Self {
61 Self::from_js_value(wasm_bindgen::JsValue::from_str(value))
62 }
63
64 #[inline]
65 pub fn from_f64(value: f64) -> Self {
66 Self::from_js_value(wasm_bindgen::JsValue::from_f64(value))
67 }
68}