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
use crate::*;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use std::fmt;
use wasmer_types::ValueType;
pub type __wasi_linkcount_t = u32;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(C)]
pub struct __wasi_subscription_clock_t {
pub userdata: __wasi_userdata_t,
pub clock_id: __wasi_clockid_t,
pub timeout: __wasi_timestamp_t,
pub precision: __wasi_timestamp_t,
pub flags: __wasi_subclockflags_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union __wasi_subscription_u {
pub clock: __wasi_subscription_clock_t,
pub fd_readwrite: __wasi_subscription_fs_readwrite_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __wasi_subscription_t {
pub userdata: __wasi_userdata_t,
pub type_: __wasi_eventtype_t,
pub u: __wasi_subscription_u,
}
unsafe impl ValueType for __wasi_subscription_t {}
pub type __wasi_whence_t = u8;
pub const __WASI_WHENCE_CUR: u8 = 0;
pub const __WASI_WHENCE_END: u8 = 1;
pub const __WASI_WHENCE_SET: u8 = 2;
#[derive(Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[repr(C)]
pub struct __wasi_filestat_t {
pub st_dev: __wasi_device_t,
pub st_ino: __wasi_inode_t,
pub st_filetype: __wasi_filetype_t,
pub st_nlink: __wasi_linkcount_t,
pub st_size: __wasi_filesize_t,
pub st_atim: __wasi_timestamp_t,
pub st_mtim: __wasi_timestamp_t,
pub st_ctim: __wasi_timestamp_t,
}
unsafe impl ValueType for __wasi_filestat_t {}
impl fmt::Debug for __wasi_filestat_t {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let convert_ts_into_time_string = |ts| {
let tspec = ::time::OffsetDateTime::from_unix_timestamp_nanos(ts);
format!("{} ({})", tspec.format("%a, %d %b %Y %T %z"), ts)
};
f.debug_struct("__wasi_filestat_t")
.field("st_dev", &self.st_dev)
.field("st_ino", &self.st_ino)
.field(
"st_filetype",
&format!(
"{} ({})",
wasi_filetype_to_name(self.st_filetype),
self.st_filetype,
),
)
.field("st_nlink", &self.st_nlink)
.field("st_size", &self.st_size)
.field(
"st_atim",
&convert_ts_into_time_string(self.st_atim as i128),
)
.field(
"st_mtim",
&convert_ts_into_time_string(self.st_mtim as i128),
)
.field(
"st_ctim",
&convert_ts_into_time_string(self.st_ctim as i128),
)
.finish()
}
}
impl fmt::Debug for __wasi_subscription_t {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("__wasi_subscription_t")
.field("userdata", &self.userdata)
.field("type", &eventtype_to_str(self.type_))
.field(
"u",
match self.type_ {
__WASI_EVENTTYPE_CLOCK => unsafe { &self.u.clock },
__WASI_EVENTTYPE_FD_READ | __WASI_EVENTTYPE_FD_WRITE => unsafe {
&self.u.fd_readwrite
},
_ => &"INVALID EVENTTYPE",
},
)
.finish()
}
}