forked from yewstack/yew
/
mod.rs
72 lines (59 loc) · 1.42 KB
/
mod.rs
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
use std::future::Future;
use std::io;
use std::marker::PhantomData;
pub(crate) mod time;
pub(crate) fn get_default_runtime_size() -> usize {
0
}
static NO_RUNTIME_NOTICE: &str = r#"No runtime configured for this platform, \
features that requires a runtime can't be used. \
Either compile with `target_arch = "wasm32", or enable the `tokio` feature."#;
fn panic_no_runtime() -> ! {
panic!("{}", NO_RUNTIME_NOTICE);
}
#[inline(always)]
pub(super) fn spawn_local<F>(_f: F)
where
F: Future<Output = ()> + 'static,
{
panic_no_runtime();
}
#[derive(Debug, Clone)]
pub(crate) struct Runtime {}
impl Default for Runtime {
fn default() -> Self {
panic_no_runtime();
}
}
impl Runtime {
pub fn new(_size: usize) -> io::Result<Self> {
panic_no_runtime();
}
pub fn spawn_pinned<F, Fut>(&self, _create_task: F)
where
F: FnOnce() -> Fut,
F: Send + 'static,
Fut: Future<Output = ()> + 'static,
{
panic_no_runtime();
}
}
#[derive(Debug, Clone)]
pub(crate) struct LocalHandle {
// This type is not send or sync.
_marker: PhantomData<*const ()>,
}
impl LocalHandle {
pub fn try_current() -> Option<Self> {
panic_no_runtime();
}
pub fn current() -> Self {
panic_no_runtime();
}
pub fn spawn_local<F>(&self, _f: F)
where
F: Future<Output = ()> + 'static,
{
panic_no_runtime();
}
}