1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use super::*;
/// The AbortSignal class.
/// [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct AbortSignal {
inner: EventTarget,
}
impl FromVal for AbortSignal {
fn from_val(v: &Any) -> Self {
AbortSignal {
inner: EventTarget::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for AbortSignal {
type Target = EventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for AbortSignal {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for AbortSignal {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for AbortSignal {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<AbortSignal> for Any {
fn from(s: AbortSignal) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&AbortSignal> for Any {
fn from(s: &AbortSignal) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(AbortSignal);
impl AbortSignal {
/// Getter of the `aborted` attribute.
/// [`AbortSignal.aborted`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/aborted)
pub fn aborted(&self) -> bool {
self.inner.get("aborted").as_::<bool>()
}
}
impl AbortSignal {
/// Getter of the `reason` attribute.
/// [`AbortSignal.reason`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/reason)
pub fn reason(&self) -> Any {
self.inner.get("reason").as_::<Any>()
}
}
impl AbortSignal {
/// Getter of the `onabort` attribute.
/// [`AbortSignal.onabort`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/onabort)
pub fn onabort(&self) -> Any {
self.inner.get("onabort").as_::<Any>()
}
/// Setter of the `onabort` attribute.
/// [`AbortSignal.onabort`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/onabort)
pub fn set_onabort(&mut self, value: &Any) {
self.inner.set("onabort", value);
}
}
impl AbortSignal {
/// The abort method.
/// [`AbortSignal.abort`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort)
pub fn abort() -> AbortSignal {
Any::global("AbortSignal")
.call("abort", &[])
.as_::<AbortSignal>()
}
}
impl AbortSignal {
/// The abort method.
/// [`AbortSignal.abort`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort)
pub fn abort_with_reason(reason: &Any) -> AbortSignal {
Any::global("AbortSignal")
.call("abort", &[reason.into()])
.as_::<AbortSignal>()
}
}
impl AbortSignal {
/// The timeout method.
/// [`AbortSignal.timeout`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout)
pub fn timeout(milliseconds: u64) -> AbortSignal {
Any::global("AbortSignal")
.call("timeout", &[milliseconds.into()])
.as_::<AbortSignal>()
}
}
impl AbortSignal {
/// The any method.
/// [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any)
pub fn any(signals: &TypedArray<AbortSignal>) -> AbortSignal {
Any::global("AbortSignal")
.call("any", &[signals.into()])
.as_::<AbortSignal>()
}
}
impl AbortSignal {
/// The throwIfAborted method.
/// [`AbortSignal.throwIfAborted`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted)
pub fn throw_if_aborted(&self) -> Undefined {
self.inner.call("throwIfAborted", &[]).as_::<Undefined>()
}
}