1use std::borrow::Cow;
2use std::time::SystemTime;
3use wasmer_wasix_types::wasi;
4use wasmer_wasix_types::wasix::{ThreadStartType, WasiMemoryLayout};
5
6use super::*;
7
8impl From<wasi::Snapshot0Clockid> for JournalSnapshot0ClockidV1 {
9 fn from(val: wasi::Snapshot0Clockid) -> Self {
10 match val {
11 wasi::Snapshot0Clockid::Realtime => JournalSnapshot0ClockidV1::Realtime,
12 wasi::Snapshot0Clockid::Monotonic => JournalSnapshot0ClockidV1::Monotonic,
13 wasi::Snapshot0Clockid::ProcessCputimeId => JournalSnapshot0ClockidV1::ProcessCputimeId,
14 wasi::Snapshot0Clockid::ThreadCputimeId => JournalSnapshot0ClockidV1::ThreadCputimeId,
15 wasi::Snapshot0Clockid::Unknown => JournalSnapshot0ClockidV1::Unknown,
16 }
17 }
18}
19
20impl From<JournalSnapshot0ClockidV1> for wasi::Snapshot0Clockid {
21 fn from(val: JournalSnapshot0ClockidV1) -> Self {
22 match val {
23 JournalSnapshot0ClockidV1::Realtime => wasi::Snapshot0Clockid::Realtime,
24 JournalSnapshot0ClockidV1::Monotonic => wasi::Snapshot0Clockid::Monotonic,
25 JournalSnapshot0ClockidV1::ProcessCputimeId => wasi::Snapshot0Clockid::ProcessCputimeId,
26 JournalSnapshot0ClockidV1::ThreadCputimeId => wasi::Snapshot0Clockid::ThreadCputimeId,
27 JournalSnapshot0ClockidV1::Unknown => wasi::Snapshot0Clockid::Unknown,
28 }
29 }
30}
31
32impl From<&'_ ArchivedJournalSnapshot0ClockidV1> for wasi::Snapshot0Clockid {
33 fn from(val: &'_ ArchivedJournalSnapshot0ClockidV1) -> Self {
34 match val {
35 ArchivedJournalSnapshot0ClockidV1::Realtime => wasi::Snapshot0Clockid::Realtime,
36 ArchivedJournalSnapshot0ClockidV1::Monotonic => wasi::Snapshot0Clockid::Monotonic,
37 ArchivedJournalSnapshot0ClockidV1::ProcessCputimeId => {
38 wasi::Snapshot0Clockid::ProcessCputimeId
39 }
40 ArchivedJournalSnapshot0ClockidV1::ThreadCputimeId => {
41 wasi::Snapshot0Clockid::ThreadCputimeId
42 }
43 ArchivedJournalSnapshot0ClockidV1::Unknown => wasi::Snapshot0Clockid::Unknown,
44 }
45 }
46}
47
48impl From<wasi::Whence> for JournalWhenceV1 {
49 fn from(val: wasi::Whence) -> Self {
50 match val {
51 wasi::Whence::Set => JournalWhenceV1::Set,
52 wasi::Whence::Cur => JournalWhenceV1::Cur,
53 wasi::Whence::End => JournalWhenceV1::End,
54 wasi::Whence::Unknown => JournalWhenceV1::Unknown,
55 }
56 }
57}
58
59impl From<JournalWhenceV1> for wasi::Whence {
60 fn from(val: JournalWhenceV1) -> Self {
61 match val {
62 JournalWhenceV1::Set => wasi::Whence::Set,
63 JournalWhenceV1::Cur => wasi::Whence::Cur,
64 JournalWhenceV1::End => wasi::Whence::End,
65 JournalWhenceV1::Unknown => wasi::Whence::Unknown,
66 }
67 }
68}
69
70impl From<&'_ ArchivedJournalWhenceV1> for wasi::Whence {
71 fn from(val: &'_ ArchivedJournalWhenceV1) -> Self {
72 match val {
73 ArchivedJournalWhenceV1::Set => wasi::Whence::Set,
74 ArchivedJournalWhenceV1::Cur => wasi::Whence::Cur,
75 ArchivedJournalWhenceV1::End => wasi::Whence::End,
76 ArchivedJournalWhenceV1::Unknown => wasi::Whence::Unknown,
77 }
78 }
79}
80
81impl From<wasi::Advice> for JournalAdviceV1 {
82 fn from(val: wasi::Advice) -> Self {
83 match val {
84 wasi::Advice::Normal => JournalAdviceV1::Normal,
85 wasi::Advice::Sequential => JournalAdviceV1::Sequential,
86 wasi::Advice::Random => JournalAdviceV1::Random,
87 wasi::Advice::Willneed => JournalAdviceV1::Willneed,
88 wasi::Advice::Dontneed => JournalAdviceV1::Dontneed,
89 wasi::Advice::Noreuse => JournalAdviceV1::Noreuse,
90 wasi::Advice::Unknown => JournalAdviceV1::Unknown,
91 }
92 }
93}
94
95impl From<JournalAdviceV1> for wasi::Advice {
96 fn from(val: JournalAdviceV1) -> Self {
97 match val {
98 JournalAdviceV1::Normal => wasi::Advice::Normal,
99 JournalAdviceV1::Sequential => wasi::Advice::Sequential,
100 JournalAdviceV1::Random => wasi::Advice::Random,
101 JournalAdviceV1::Willneed => wasi::Advice::Willneed,
102 JournalAdviceV1::Dontneed => wasi::Advice::Dontneed,
103 JournalAdviceV1::Noreuse => wasi::Advice::Noreuse,
104 JournalAdviceV1::Unknown => wasi::Advice::Unknown,
105 }
106 }
107}
108
109impl From<&'_ ArchivedJournalAdviceV1> for wasi::Advice {
110 fn from(val: &'_ ArchivedJournalAdviceV1) -> Self {
111 match val {
112 ArchivedJournalAdviceV1::Normal => wasi::Advice::Normal,
113 ArchivedJournalAdviceV1::Sequential => wasi::Advice::Sequential,
114 ArchivedJournalAdviceV1::Random => wasi::Advice::Random,
115 ArchivedJournalAdviceV1::Willneed => wasi::Advice::Willneed,
116 ArchivedJournalAdviceV1::Dontneed => wasi::Advice::Dontneed,
117 ArchivedJournalAdviceV1::Noreuse => wasi::Advice::Noreuse,
118 ArchivedJournalAdviceV1::Unknown => wasi::Advice::Unknown,
119 }
120 }
121}
122
123impl From<virtual_net::IpCidr> for JournalIpCidrV1 {
124 fn from(value: virtual_net::IpCidr) -> Self {
125 Self {
126 ip: value.ip,
127 prefix: value.prefix,
128 }
129 }
130}
131
132impl From<JournalIpCidrV1> for virtual_net::IpCidr {
133 fn from(value: JournalIpCidrV1) -> Self {
134 Self {
135 ip: value.ip,
136 prefix: value.prefix,
137 }
138 }
139}
140
141impl From<wasi::ExitCode> for JournalExitCodeV1 {
142 fn from(val: wasi::ExitCode) -> Self {
143 JournalExitCodeV1::Other(val.raw())
144 }
145}
146
147impl From<JournalExitCodeV1> for wasi::ExitCode {
148 fn from(val: JournalExitCodeV1) -> Self {
149 match val {
150 JournalExitCodeV1::Errno(errno) => wasi::ExitCode::from(errno),
151 JournalExitCodeV1::Other(id) => wasi::ExitCode::from(id),
152 }
153 }
154}
155
156impl From<&'_ ArchivedJournalExitCodeV1> for wasi::ExitCode {
157 fn from(val: &'_ ArchivedJournalExitCodeV1) -> Self {
158 match val {
159 ArchivedJournalExitCodeV1::Errno(errno) => wasi::ExitCode::from(errno.to_native()),
160 ArchivedJournalExitCodeV1::Other(id) => wasi::ExitCode::from(id.to_native()),
161 }
162 }
163}
164
165impl From<SnapshotTrigger> for JournalSnapshotTriggerV1 {
166 fn from(val: SnapshotTrigger) -> Self {
167 match val {
168 SnapshotTrigger::Idle => JournalSnapshotTriggerV1::Idle,
169 SnapshotTrigger::FirstListen => JournalSnapshotTriggerV1::Listen,
170 SnapshotTrigger::FirstEnviron => JournalSnapshotTriggerV1::Environ,
171 SnapshotTrigger::FirstStdin => JournalSnapshotTriggerV1::Stdin,
172 SnapshotTrigger::FirstSigint => JournalSnapshotTriggerV1::Sigint,
173 SnapshotTrigger::PeriodicInterval => JournalSnapshotTriggerV1::Timer,
174 SnapshotTrigger::Sigint => JournalSnapshotTriggerV1::Sigint,
175 SnapshotTrigger::Sigalrm => JournalSnapshotTriggerV1::Sigalrm,
176 SnapshotTrigger::Sigtstp => JournalSnapshotTriggerV1::Sigtstp,
177 SnapshotTrigger::Sigstop => JournalSnapshotTriggerV1::Sigstop,
178 SnapshotTrigger::NonDeterministicCall => JournalSnapshotTriggerV1::NonDeterministicCall,
179 SnapshotTrigger::Bootstrap => JournalSnapshotTriggerV1::Bootstrap,
180 SnapshotTrigger::Transaction => JournalSnapshotTriggerV1::Transaction,
181 SnapshotTrigger::Explicit => JournalSnapshotTriggerV1::Explicit,
182 }
183 }
184}
185
186impl From<JournalSnapshotTriggerV1> for SnapshotTrigger {
187 fn from(val: JournalSnapshotTriggerV1) -> Self {
188 match val {
189 JournalSnapshotTriggerV1::Idle => SnapshotTrigger::Idle,
190 JournalSnapshotTriggerV1::Listen => SnapshotTrigger::FirstListen,
191 JournalSnapshotTriggerV1::Environ => SnapshotTrigger::FirstEnviron,
192 JournalSnapshotTriggerV1::Stdin => SnapshotTrigger::FirstStdin,
193 JournalSnapshotTriggerV1::Timer => SnapshotTrigger::PeriodicInterval,
194 JournalSnapshotTriggerV1::Sigint => SnapshotTrigger::Sigint,
195 JournalSnapshotTriggerV1::Sigalrm => SnapshotTrigger::Sigalrm,
196 JournalSnapshotTriggerV1::Sigtstp => SnapshotTrigger::Sigtstp,
197 JournalSnapshotTriggerV1::Sigstop => SnapshotTrigger::Sigstop,
198 JournalSnapshotTriggerV1::NonDeterministicCall => SnapshotTrigger::NonDeterministicCall,
199 JournalSnapshotTriggerV1::Bootstrap => SnapshotTrigger::Bootstrap,
200 JournalSnapshotTriggerV1::Transaction => SnapshotTrigger::Transaction,
201 JournalSnapshotTriggerV1::Explicit => SnapshotTrigger::Explicit,
202 }
203 }
204}
205
206impl From<&'_ ArchivedJournalSnapshotTriggerV1> for SnapshotTrigger {
207 fn from(val: &'_ ArchivedJournalSnapshotTriggerV1) -> Self {
208 match val {
209 ArchivedJournalSnapshotTriggerV1::Idle => SnapshotTrigger::Idle,
210 ArchivedJournalSnapshotTriggerV1::Listen => SnapshotTrigger::FirstListen,
211 ArchivedJournalSnapshotTriggerV1::Environ => SnapshotTrigger::FirstEnviron,
212 ArchivedJournalSnapshotTriggerV1::Stdin => SnapshotTrigger::FirstStdin,
213 ArchivedJournalSnapshotTriggerV1::Timer => SnapshotTrigger::PeriodicInterval,
214 ArchivedJournalSnapshotTriggerV1::Sigint => SnapshotTrigger::Sigint,
215 ArchivedJournalSnapshotTriggerV1::Sigalrm => SnapshotTrigger::Sigalrm,
216 ArchivedJournalSnapshotTriggerV1::Sigtstp => SnapshotTrigger::Sigtstp,
217 ArchivedJournalSnapshotTriggerV1::Sigstop => SnapshotTrigger::Sigstop,
218 ArchivedJournalSnapshotTriggerV1::NonDeterministicCall => {
219 SnapshotTrigger::NonDeterministicCall
220 }
221 ArchivedJournalSnapshotTriggerV1::Bootstrap => SnapshotTrigger::Bootstrap,
222 ArchivedJournalSnapshotTriggerV1::Transaction => SnapshotTrigger::Transaction,
223 ArchivedJournalSnapshotTriggerV1::Explicit => SnapshotTrigger::Explicit,
224 }
225 }
226}
227
228impl From<wasi::EpollCtl> for JournalEpollCtlV1 {
229 fn from(val: wasi::EpollCtl) -> Self {
230 match val {
231 wasi::EpollCtl::Add => JournalEpollCtlV1::Add,
232 wasi::EpollCtl::Mod => JournalEpollCtlV1::Mod,
233 wasi::EpollCtl::Del => JournalEpollCtlV1::Del,
234 wasi::EpollCtl::Unknown => JournalEpollCtlV1::Unknown,
235 }
236 }
237}
238
239impl From<JournalEpollCtlV1> for wasi::EpollCtl {
240 fn from(val: JournalEpollCtlV1) -> Self {
241 match val {
242 JournalEpollCtlV1::Add => wasi::EpollCtl::Add,
243 JournalEpollCtlV1::Mod => wasi::EpollCtl::Mod,
244 JournalEpollCtlV1::Del => wasi::EpollCtl::Del,
245 JournalEpollCtlV1::Unknown => wasi::EpollCtl::Unknown,
246 }
247 }
248}
249
250impl From<&'_ ArchivedJournalEpollCtlV1> for wasi::EpollCtl {
251 fn from(val: &'_ ArchivedJournalEpollCtlV1) -> Self {
252 match val {
253 ArchivedJournalEpollCtlV1::Add => wasi::EpollCtl::Add,
254 ArchivedJournalEpollCtlV1::Mod => wasi::EpollCtl::Mod,
255 ArchivedJournalEpollCtlV1::Del => wasi::EpollCtl::Del,
256 ArchivedJournalEpollCtlV1::Unknown => wasi::EpollCtl::Unknown,
257 }
258 }
259}
260
261impl From<wasi::EpollEventCtl> for JournalEpollEventCtlV1 {
262 fn from(val: wasi::EpollEventCtl) -> Self {
263 JournalEpollEventCtlV1 {
264 events: val.events.bits(),
265 ptr: val.ptr,
266 fd: val.fd,
267 data1: val.data1,
268 data2: val.data2,
269 }
270 }
271}
272
273impl From<JournalEpollEventCtlV1> for wasi::EpollEventCtl {
274 fn from(val: JournalEpollEventCtlV1) -> Self {
275 Self {
276 events: wasi::EpollType::from_bits_truncate(val.events),
277 ptr: val.ptr,
278 fd: val.fd,
279 data1: val.data1,
280 data2: val.data2,
281 }
282 }
283}
284
285impl From<&'_ ArchivedJournalEpollEventCtlV1> for wasi::EpollEventCtl {
286 fn from(val: &'_ ArchivedJournalEpollEventCtlV1) -> Self {
287 Self {
288 events: wasi::EpollType::from_bits_truncate(val.events.to_native()),
289 ptr: val.ptr.to_native(),
290 fd: val.fd.to_native(),
291 data1: val.data1.to_native(),
292 data2: val.data2.to_native(),
293 }
294 }
295}
296
297impl From<virtual_net::StreamSecurity> for JournalStreamSecurityV1 {
298 fn from(val: virtual_net::StreamSecurity) -> Self {
299 use virtual_net::StreamSecurity;
300 match val {
301 StreamSecurity::Unencrypted => JournalStreamSecurityV1::Unencrypted,
302 StreamSecurity::AnyEncyption => JournalStreamSecurityV1::AnyEncryption,
303 StreamSecurity::ClassicEncryption => JournalStreamSecurityV1::ClassicEncryption,
304 StreamSecurity::DoubleEncryption => JournalStreamSecurityV1::DoubleEncryption,
305 }
306 }
307}
308
309impl From<JournalStreamSecurityV1> for virtual_net::StreamSecurity {
310 fn from(val: JournalStreamSecurityV1) -> Self {
311 use virtual_net::StreamSecurity;
312 match val {
313 JournalStreamSecurityV1::Unencrypted => StreamSecurity::Unencrypted,
314 JournalStreamSecurityV1::AnyEncryption => StreamSecurity::AnyEncyption,
315 JournalStreamSecurityV1::ClassicEncryption => StreamSecurity::ClassicEncryption,
316 JournalStreamSecurityV1::DoubleEncryption => StreamSecurity::DoubleEncryption,
317 JournalStreamSecurityV1::Unknown => StreamSecurity::AnyEncyption,
318 }
319 }
320}
321
322impl From<&'_ ArchivedJournalStreamSecurityV1> for virtual_net::StreamSecurity {
323 fn from(val: &'_ ArchivedJournalStreamSecurityV1) -> Self {
324 use virtual_net::StreamSecurity;
325 match val {
326 ArchivedJournalStreamSecurityV1::Unencrypted => StreamSecurity::Unencrypted,
327 ArchivedJournalStreamSecurityV1::AnyEncryption => StreamSecurity::AnyEncyption,
328 ArchivedJournalStreamSecurityV1::ClassicEncryption => StreamSecurity::ClassicEncryption,
329 ArchivedJournalStreamSecurityV1::DoubleEncryption => StreamSecurity::DoubleEncryption,
330 ArchivedJournalStreamSecurityV1::Unknown => StreamSecurity::AnyEncyption,
331 }
332 }
333}
334
335impl From<wasi::Addressfamily> for JournalAddressfamilyV1 {
336 fn from(val: wasi::Addressfamily) -> Self {
337 match val {
338 wasi::Addressfamily::Unspec => JournalAddressfamilyV1::Unspec,
339 wasi::Addressfamily::Inet4 => JournalAddressfamilyV1::Inet4,
340 wasi::Addressfamily::Inet6 => JournalAddressfamilyV1::Inet6,
341 wasi::Addressfamily::Unix => JournalAddressfamilyV1::Unix,
342 }
343 }
344}
345
346impl From<JournalAddressfamilyV1> for wasi::Addressfamily {
347 fn from(val: JournalAddressfamilyV1) -> Self {
348 match val {
349 JournalAddressfamilyV1::Unspec => wasi::Addressfamily::Unspec,
350 JournalAddressfamilyV1::Inet4 => wasi::Addressfamily::Inet4,
351 JournalAddressfamilyV1::Inet6 => wasi::Addressfamily::Inet6,
352 JournalAddressfamilyV1::Unix => wasi::Addressfamily::Unix,
353 }
354 }
355}
356
357impl From<&'_ ArchivedJournalAddressfamilyV1> for wasi::Addressfamily {
358 fn from(val: &'_ ArchivedJournalAddressfamilyV1) -> Self {
359 match val {
360 ArchivedJournalAddressfamilyV1::Unspec => wasi::Addressfamily::Unspec,
361 ArchivedJournalAddressfamilyV1::Inet4 => wasi::Addressfamily::Inet4,
362 ArchivedJournalAddressfamilyV1::Inet6 => wasi::Addressfamily::Inet6,
363 ArchivedJournalAddressfamilyV1::Unix => wasi::Addressfamily::Unix,
364 }
365 }
366}
367
368impl From<wasi::Socktype> for JournalSocktypeV1 {
369 fn from(val: wasi::Socktype) -> Self {
370 match val {
371 wasi::Socktype::Stream => JournalSocktypeV1::Stream,
372 wasi::Socktype::Dgram => JournalSocktypeV1::Dgram,
373 wasi::Socktype::Raw => JournalSocktypeV1::Raw,
374 wasi::Socktype::Seqpacket => JournalSocktypeV1::Seqpacket,
375 wasi::Socktype::Unknown => JournalSocktypeV1::Unknown,
376 }
377 }
378}
379
380impl From<JournalSocktypeV1> for wasi::Socktype {
381 fn from(val: JournalSocktypeV1) -> Self {
382 match val {
383 JournalSocktypeV1::Stream => wasi::Socktype::Stream,
384 JournalSocktypeV1::Dgram => wasi::Socktype::Dgram,
385 JournalSocktypeV1::Raw => wasi::Socktype::Raw,
386 JournalSocktypeV1::Seqpacket => wasi::Socktype::Seqpacket,
387 JournalSocktypeV1::Unknown => wasi::Socktype::Unknown,
388 }
389 }
390}
391
392impl From<&'_ ArchivedJournalSocktypeV1> for wasi::Socktype {
393 fn from(val: &'_ ArchivedJournalSocktypeV1) -> Self {
394 match val {
395 ArchivedJournalSocktypeV1::Stream => wasi::Socktype::Stream,
396 ArchivedJournalSocktypeV1::Dgram => wasi::Socktype::Dgram,
397 ArchivedJournalSocktypeV1::Raw => wasi::Socktype::Raw,
398 ArchivedJournalSocktypeV1::Seqpacket => wasi::Socktype::Seqpacket,
399 ArchivedJournalSocktypeV1::Unknown => wasi::Socktype::Unknown,
400 }
401 }
402}
403
404impl From<wasi::Sockoption> for JournalSockoptionV1 {
405 fn from(val: wasi::Sockoption) -> Self {
406 match val {
407 wasi::Sockoption::Noop => JournalSockoptionV1::Noop,
408 wasi::Sockoption::ReusePort => JournalSockoptionV1::ReusePort,
409 wasi::Sockoption::ReuseAddr => JournalSockoptionV1::ReuseAddr,
410 wasi::Sockoption::NoDelay => JournalSockoptionV1::NoDelay,
411 wasi::Sockoption::DontRoute => JournalSockoptionV1::DontRoute,
412 wasi::Sockoption::OnlyV6 => JournalSockoptionV1::OnlyV6,
413 wasi::Sockoption::Broadcast => JournalSockoptionV1::Broadcast,
414 wasi::Sockoption::MulticastLoopV4 => JournalSockoptionV1::MulticastLoopV4,
415 wasi::Sockoption::MulticastLoopV6 => JournalSockoptionV1::MulticastLoopV6,
416 wasi::Sockoption::Promiscuous => JournalSockoptionV1::Promiscuous,
417 wasi::Sockoption::Listening => JournalSockoptionV1::Listening,
418 wasi::Sockoption::LastError => JournalSockoptionV1::LastError,
419 wasi::Sockoption::KeepAlive => JournalSockoptionV1::KeepAlive,
420 wasi::Sockoption::Linger => JournalSockoptionV1::Linger,
421 wasi::Sockoption::OobInline => JournalSockoptionV1::OobInline,
422 wasi::Sockoption::RecvBufSize => JournalSockoptionV1::RecvBufSize,
423 wasi::Sockoption::SendBufSize => JournalSockoptionV1::SendBufSize,
424 wasi::Sockoption::RecvLowat => JournalSockoptionV1::RecvLowat,
425 wasi::Sockoption::SendLowat => JournalSockoptionV1::SendLowat,
426 wasi::Sockoption::RecvTimeout => JournalSockoptionV1::RecvTimeout,
427 wasi::Sockoption::SendTimeout => JournalSockoptionV1::SendTimeout,
428 wasi::Sockoption::ConnectTimeout => JournalSockoptionV1::ConnectTimeout,
429 wasi::Sockoption::AcceptTimeout => JournalSockoptionV1::AcceptTimeout,
430 wasi::Sockoption::Ttl => JournalSockoptionV1::Ttl,
431 wasi::Sockoption::MulticastTtlV4 => JournalSockoptionV1::MulticastTtlV4,
432 wasi::Sockoption::Type => JournalSockoptionV1::Type,
433 wasi::Sockoption::Proto => JournalSockoptionV1::Proto,
434 }
435 }
436}
437
438impl From<JournalSockoptionV1> for wasi::Sockoption {
439 fn from(val: JournalSockoptionV1) -> Self {
440 match val {
441 JournalSockoptionV1::Noop => wasi::Sockoption::Noop,
442 JournalSockoptionV1::ReusePort => wasi::Sockoption::ReusePort,
443 JournalSockoptionV1::ReuseAddr => wasi::Sockoption::ReuseAddr,
444 JournalSockoptionV1::NoDelay => wasi::Sockoption::NoDelay,
445 JournalSockoptionV1::DontRoute => wasi::Sockoption::DontRoute,
446 JournalSockoptionV1::OnlyV6 => wasi::Sockoption::OnlyV6,
447 JournalSockoptionV1::Broadcast => wasi::Sockoption::Broadcast,
448 JournalSockoptionV1::MulticastLoopV4 => wasi::Sockoption::MulticastLoopV4,
449 JournalSockoptionV1::MulticastLoopV6 => wasi::Sockoption::MulticastLoopV6,
450 JournalSockoptionV1::Promiscuous => wasi::Sockoption::Promiscuous,
451 JournalSockoptionV1::Listening => wasi::Sockoption::Listening,
452 JournalSockoptionV1::LastError => wasi::Sockoption::LastError,
453 JournalSockoptionV1::KeepAlive => wasi::Sockoption::KeepAlive,
454 JournalSockoptionV1::Linger => wasi::Sockoption::Linger,
455 JournalSockoptionV1::OobInline => wasi::Sockoption::OobInline,
456 JournalSockoptionV1::RecvBufSize => wasi::Sockoption::RecvBufSize,
457 JournalSockoptionV1::SendBufSize => wasi::Sockoption::SendBufSize,
458 JournalSockoptionV1::RecvLowat => wasi::Sockoption::RecvLowat,
459 JournalSockoptionV1::SendLowat => wasi::Sockoption::SendLowat,
460 JournalSockoptionV1::RecvTimeout => wasi::Sockoption::RecvTimeout,
461 JournalSockoptionV1::SendTimeout => wasi::Sockoption::SendTimeout,
462 JournalSockoptionV1::ConnectTimeout => wasi::Sockoption::ConnectTimeout,
463 JournalSockoptionV1::AcceptTimeout => wasi::Sockoption::AcceptTimeout,
464 JournalSockoptionV1::Ttl => wasi::Sockoption::Ttl,
465 JournalSockoptionV1::MulticastTtlV4 => wasi::Sockoption::MulticastTtlV4,
466 JournalSockoptionV1::Type => wasi::Sockoption::Type,
467 JournalSockoptionV1::Proto => wasi::Sockoption::Proto,
468 }
469 }
470}
471
472impl From<&'_ ArchivedJournalSockoptionV1> for wasi::Sockoption {
473 fn from(val: &'_ ArchivedJournalSockoptionV1) -> Self {
474 match val {
475 ArchivedJournalSockoptionV1::Noop => wasi::Sockoption::Noop,
476 ArchivedJournalSockoptionV1::ReusePort => wasi::Sockoption::ReusePort,
477 ArchivedJournalSockoptionV1::ReuseAddr => wasi::Sockoption::ReuseAddr,
478 ArchivedJournalSockoptionV1::NoDelay => wasi::Sockoption::NoDelay,
479 ArchivedJournalSockoptionV1::DontRoute => wasi::Sockoption::DontRoute,
480 ArchivedJournalSockoptionV1::OnlyV6 => wasi::Sockoption::OnlyV6,
481 ArchivedJournalSockoptionV1::Broadcast => wasi::Sockoption::Broadcast,
482 ArchivedJournalSockoptionV1::MulticastLoopV4 => wasi::Sockoption::MulticastLoopV4,
483 ArchivedJournalSockoptionV1::MulticastLoopV6 => wasi::Sockoption::MulticastLoopV6,
484 ArchivedJournalSockoptionV1::Promiscuous => wasi::Sockoption::Promiscuous,
485 ArchivedJournalSockoptionV1::Listening => wasi::Sockoption::Listening,
486 ArchivedJournalSockoptionV1::LastError => wasi::Sockoption::LastError,
487 ArchivedJournalSockoptionV1::KeepAlive => wasi::Sockoption::KeepAlive,
488 ArchivedJournalSockoptionV1::Linger => wasi::Sockoption::Linger,
489 ArchivedJournalSockoptionV1::OobInline => wasi::Sockoption::OobInline,
490 ArchivedJournalSockoptionV1::RecvBufSize => wasi::Sockoption::RecvBufSize,
491 ArchivedJournalSockoptionV1::SendBufSize => wasi::Sockoption::SendBufSize,
492 ArchivedJournalSockoptionV1::RecvLowat => wasi::Sockoption::RecvLowat,
493 ArchivedJournalSockoptionV1::SendLowat => wasi::Sockoption::SendLowat,
494 ArchivedJournalSockoptionV1::RecvTimeout => wasi::Sockoption::RecvTimeout,
495 ArchivedJournalSockoptionV1::SendTimeout => wasi::Sockoption::SendTimeout,
496 ArchivedJournalSockoptionV1::ConnectTimeout => wasi::Sockoption::ConnectTimeout,
497 ArchivedJournalSockoptionV1::AcceptTimeout => wasi::Sockoption::AcceptTimeout,
498 ArchivedJournalSockoptionV1::Ttl => wasi::Sockoption::Ttl,
499 ArchivedJournalSockoptionV1::MulticastTtlV4 => wasi::Sockoption::MulticastTtlV4,
500 ArchivedJournalSockoptionV1::Type => wasi::Sockoption::Type,
501 ArchivedJournalSockoptionV1::Proto => wasi::Sockoption::Proto,
502 }
503 }
504}
505
506impl From<SocketOptTimeType> for JournalTimeTypeV1 {
507 fn from(val: SocketOptTimeType) -> Self {
508 match val {
509 SocketOptTimeType::ReadTimeout => JournalTimeTypeV1::ReadTimeout,
510 SocketOptTimeType::WriteTimeout => JournalTimeTypeV1::WriteTimeout,
511 SocketOptTimeType::AcceptTimeout => JournalTimeTypeV1::AcceptTimeout,
512 SocketOptTimeType::ConnectTimeout => JournalTimeTypeV1::ConnectTimeout,
513 SocketOptTimeType::BindTimeout => JournalTimeTypeV1::BindTimeout,
514 SocketOptTimeType::Linger => JournalTimeTypeV1::Linger,
515 }
516 }
517}
518
519impl From<JournalTimeTypeV1> for SocketOptTimeType {
520 fn from(val: JournalTimeTypeV1) -> Self {
521 match val {
522 JournalTimeTypeV1::ReadTimeout => SocketOptTimeType::ReadTimeout,
523 JournalTimeTypeV1::WriteTimeout => SocketOptTimeType::WriteTimeout,
524 JournalTimeTypeV1::AcceptTimeout => SocketOptTimeType::AcceptTimeout,
525 JournalTimeTypeV1::ConnectTimeout => SocketOptTimeType::ConnectTimeout,
526 JournalTimeTypeV1::BindTimeout => SocketOptTimeType::BindTimeout,
527 JournalTimeTypeV1::Linger => SocketOptTimeType::Linger,
528 }
529 }
530}
531
532impl From<&'_ ArchivedJournalTimeTypeV1> for SocketOptTimeType {
533 fn from(val: &'_ ArchivedJournalTimeTypeV1) -> Self {
534 match val {
535 ArchivedJournalTimeTypeV1::ReadTimeout => SocketOptTimeType::ReadTimeout,
536 ArchivedJournalTimeTypeV1::WriteTimeout => SocketOptTimeType::WriteTimeout,
537 ArchivedJournalTimeTypeV1::AcceptTimeout => SocketOptTimeType::AcceptTimeout,
538 ArchivedJournalTimeTypeV1::ConnectTimeout => SocketOptTimeType::ConnectTimeout,
539 ArchivedJournalTimeTypeV1::BindTimeout => SocketOptTimeType::BindTimeout,
540 ArchivedJournalTimeTypeV1::Linger => SocketOptTimeType::Linger,
541 }
542 }
543}
544
545impl From<SocketShutdownHow> for JournalSocketShutdownV1 {
546 fn from(val: SocketShutdownHow) -> Self {
547 match val {
548 SocketShutdownHow::Read => JournalSocketShutdownV1::Read,
549 SocketShutdownHow::Write => JournalSocketShutdownV1::Write,
550 SocketShutdownHow::Both => JournalSocketShutdownV1::Both,
551 }
552 }
553}
554
555impl From<JournalSocketShutdownV1> for SocketShutdownHow {
556 fn from(val: JournalSocketShutdownV1) -> Self {
557 match val {
558 JournalSocketShutdownV1::Read => SocketShutdownHow::Read,
559 JournalSocketShutdownV1::Write => SocketShutdownHow::Write,
560 JournalSocketShutdownV1::Both => SocketShutdownHow::Both,
561 }
562 }
563}
564
565impl From<&'_ ArchivedJournalSocketShutdownV1> for SocketShutdownHow {
566 fn from(val: &'_ ArchivedJournalSocketShutdownV1) -> Self {
567 match val {
568 ArchivedJournalSocketShutdownV1::Read => SocketShutdownHow::Read,
569 ArchivedJournalSocketShutdownV1::Write => SocketShutdownHow::Write,
570 ArchivedJournalSocketShutdownV1::Both => SocketShutdownHow::Both,
571 }
572 }
573}
574
575impl From<JournalThreadStartTypeV1> for ThreadStartType {
576 fn from(value: JournalThreadStartTypeV1) -> Self {
577 match value {
578 JournalThreadStartTypeV1::MainThread => ThreadStartType::MainThread,
579 JournalThreadStartTypeV1::ThreadSpawn { start_ptr } => {
580 ThreadStartType::ThreadSpawn { start_ptr }
581 }
582 }
583 }
584}
585
586impl From<&'_ ArchivedJournalThreadStartTypeV1> for ThreadStartType {
587 fn from(value: &'_ ArchivedJournalThreadStartTypeV1) -> Self {
588 match value {
589 ArchivedJournalThreadStartTypeV1::MainThread => ThreadStartType::MainThread,
590 ArchivedJournalThreadStartTypeV1::ThreadSpawn { start_ptr } => {
591 ThreadStartType::ThreadSpawn {
592 start_ptr: start_ptr.to_native(),
593 }
594 }
595 }
596 }
597}
598
599impl From<ThreadStartType> for JournalThreadStartTypeV1 {
600 fn from(value: ThreadStartType) -> Self {
601 match value {
602 ThreadStartType::MainThread => JournalThreadStartTypeV1::MainThread,
603 ThreadStartType::ThreadSpawn { start_ptr } => {
604 JournalThreadStartTypeV1::ThreadSpawn { start_ptr }
605 }
606 }
607 }
608}
609
610impl From<JournalWasiMemoryLayout> for WasiMemoryLayout {
611 fn from(value: JournalWasiMemoryLayout) -> Self {
612 Self {
613 stack_upper: value.stack_upper,
614 stack_lower: value.stack_lower,
615 guard_size: value.guard_size,
616 stack_size: value.stack_size,
617 tls_base: None,
618 }
619 }
620}
621
622impl From<&'_ ArchivedJournalWasiMemoryLayout> for WasiMemoryLayout {
623 fn from(value: &'_ ArchivedJournalWasiMemoryLayout) -> Self {
624 Self {
625 stack_upper: value.stack_upper.to_native(),
626 stack_lower: value.stack_lower.to_native(),
627 guard_size: value.guard_size.to_native(),
628 stack_size: value.stack_size.to_native(),
629 tls_base: None,
630 }
631 }
632}
633
634impl From<WasiMemoryLayout> for JournalWasiMemoryLayout {
635 fn from(value: WasiMemoryLayout) -> Self {
636 Self {
637 stack_upper: value.stack_upper,
638 stack_lower: value.stack_lower,
639 guard_size: value.guard_size,
640 stack_size: value.stack_size,
641 }
642 }
643}
644
645impl<'a> TryFrom<ArchivedJournalEntry<'a>> for JournalEntry<'a> {
646 type Error = anyhow::Error;
647
648 fn try_from(value: ArchivedJournalEntry<'a>) -> anyhow::Result<Self> {
649 Ok(match value {
650 ArchivedJournalEntry::InitModuleV1(ArchivedJournalEntryInitModuleV1 { wasm_hash }) => {
651 Self::InitModuleV1 {
652 wasm_hash: Box::from(wasm_hash.get()),
653 }
654 }
655 ArchivedJournalEntry::ClearEtherealV1(ArchivedJournalEntryClearEtherealV1 {
656 ..
657 }) => Self::ClearEtherealV1,
658 ArchivedJournalEntry::UpdateMemoryRegionV1(
659 ArchivedJournalEntryUpdateMemoryRegionV1 {
660 start,
661 end,
662 compressed_data,
663 },
664 ) => Self::UpdateMemoryRegionV1 {
665 region: (start.to_native())..(end.to_native()),
666 compressed_data: Cow::Borrowed(compressed_data.as_ref()),
667 },
668 ArchivedJournalEntry::ProcessExitV1(ArchivedJournalEntryProcessExitV1 {
669 exit_code,
670 }) => Self::ProcessExitV1 {
671 exit_code: exit_code.as_ref().map(|code| code.into()),
672 },
673 ArchivedJournalEntry::SetThreadV1(ArchivedJournalEntrySetThreadV1 {
674 id,
675 call_stack,
676 memory_stack,
677 store_data,
678 is_64bit,
679 start,
680 layout,
681 }) => Self::SetThreadV1 {
682 id: id.to_native(),
683 call_stack: call_stack.as_ref().into(),
684 memory_stack: memory_stack.as_ref().into(),
685 store_data: store_data.as_ref().into(),
686 start: start.into(),
687 layout: layout.into(),
688 is_64bit: *is_64bit,
689 },
690 ArchivedJournalEntry::CloseThreadV1(ArchivedJournalEntryCloseThreadV1 {
691 id,
692 exit_code,
693 }) => Self::CloseThreadV1 {
694 id: id.to_native(),
695 exit_code: exit_code.as_ref().map(|code| code.into()),
696 },
697 ArchivedJournalEntry::FileDescriptorWriteV1(
698 ArchivedJournalEntryFileDescriptorWriteV1 {
699 data,
700 fd,
701 offset,
702 is_64bit,
703 },
704 ) => Self::FileDescriptorWriteV1 {
705 data: data.as_ref().into(),
706 fd: fd.to_native(),
707 offset: offset.to_native(),
708 is_64bit: *is_64bit,
709 },
710 ArchivedJournalEntry::FileDescriptorSeekV1(
711 ArchivedJournalEntryFileDescriptorSeekV1 { fd, offset, whence },
712 ) => Self::FileDescriptorSeekV1 {
713 fd: fd.to_native(),
714 offset: offset.to_native(),
715 whence: whence.into(),
716 },
717 ArchivedJournalEntry::OpenFileDescriptorV1(
718 ArchivedJournalEntryOpenFileDescriptorV1 {
719 fd,
720 dirfd,
721 dirflags,
722 path,
723 o_flags,
724 fs_rights_base,
725 fs_rights_inheriting,
726 fs_flags,
727 },
728 ) => Self::OpenFileDescriptorV1 {
729 fd: fd.to_native(),
730 dirfd: dirfd.to_native(),
731 dirflags: dirflags.to_native(),
732 path: String::from_utf8_lossy(path.as_ref()),
733 o_flags: wasi::Oflags::from_bits_truncate(o_flags.to_native()),
734 fs_rights_base: wasi::Rights::from_bits_truncate(fs_rights_base.to_native()),
735 fs_rights_inheriting: wasi::Rights::from_bits_truncate(
736 fs_rights_inheriting.to_native(),
737 ),
738 fs_flags: wasi::Fdflags::from_bits_truncate(fs_flags.to_native()),
739 },
740 ArchivedJournalEntry::OpenFileDescriptorV2(
741 ArchivedJournalEntryOpenFileDescriptorV2 {
742 fd,
743 dirfd,
744 dirflags,
745 path,
746 o_flags,
747 fs_rights_base,
748 fs_rights_inheriting,
749 fs_flags,
750 fd_flags,
751 },
752 ) => Self::OpenFileDescriptorV2 {
753 fd: fd.to_native(),
754 dirfd: dirfd.to_native(),
755 dirflags: dirflags.to_native(),
756 path: String::from_utf8_lossy(path.as_ref()),
757 o_flags: wasi::Oflags::from_bits_truncate(o_flags.to_native()),
758 fs_rights_base: wasi::Rights::from_bits_truncate(fs_rights_base.to_native()),
759 fs_rights_inheriting: wasi::Rights::from_bits_truncate(
760 fs_rights_inheriting.to_native(),
761 ),
762 fs_flags: wasi::Fdflags::from_bits_truncate(fs_flags.to_native()),
763 fd_flags: wasi::Fdflagsext::from_bits_truncate(fd_flags.to_native()),
764 },
765 ArchivedJournalEntry::CloseFileDescriptorV1(
766 ArchivedJournalEntryCloseFileDescriptorV1 { fd },
767 ) => Self::CloseFileDescriptorV1 { fd: fd.to_native() },
768 ArchivedJournalEntry::RemoveDirectoryV1(ArchivedJournalEntryRemoveDirectoryV1 {
769 fd,
770 path,
771 }) => Self::RemoveDirectoryV1 {
772 fd: fd.to_native(),
773 path: String::from_utf8_lossy(path.as_ref()),
774 },
775 ArchivedJournalEntry::UnlinkFileV1(ArchivedJournalEntryUnlinkFileV1 { fd, path }) => {
776 Self::UnlinkFileV1 {
777 fd: fd.to_native(),
778 path: String::from_utf8_lossy(path.as_ref()),
779 }
780 }
781 ArchivedJournalEntry::PathRenameV1(ArchivedJournalEntryPathRenameV1 {
782 old_fd,
783 old_path,
784 new_fd,
785 new_path,
786 }) => Self::PathRenameV1 {
787 old_fd: old_fd.to_native(),
788 old_path: String::from_utf8_lossy(old_path.as_ref()),
789 new_fd: new_fd.to_native(),
790 new_path: String::from_utf8_lossy(new_path.as_ref()),
791 },
792 ArchivedJournalEntry::SnapshotV1(ArchivedJournalEntrySnapshotV1 {
793 since_epoch,
794 trigger,
795 }) => Self::SnapshotV1 {
796 when: SystemTime::UNIX_EPOCH
797 .checked_add((*since_epoch).into())
798 .unwrap_or(SystemTime::UNIX_EPOCH),
799 trigger: trigger.into(),
800 },
801 ArchivedJournalEntry::SetClockTimeV1(ArchivedJournalEntrySetClockTimeV1 {
802 clock_id,
803 time,
804 }) => Self::SetClockTimeV1 {
805 clock_id: clock_id.into(),
806 time: time.to_native(),
807 },
808 ArchivedJournalEntry::RenumberFileDescriptorV1(
809 ArchivedJournalEntryRenumberFileDescriptorV1 { old_fd, new_fd },
810 ) => Self::RenumberFileDescriptorV1 {
811 old_fd: old_fd.to_native(),
812 new_fd: new_fd.to_native(),
813 },
814 ArchivedJournalEntry::DuplicateFileDescriptorV1(
815 ArchivedJournalEntryDuplicateFileDescriptorV1 {
816 original_fd: old_fd,
817 copied_fd: new_fd,
818 },
819 ) => Self::DuplicateFileDescriptorV1 {
820 original_fd: old_fd.to_native(),
821 copied_fd: new_fd.to_native(),
822 },
823 ArchivedJournalEntry::DuplicateFileDescriptorV2(
824 ArchivedJournalEntryDuplicateFileDescriptorV2 {
825 original_fd: old_fd,
826 copied_fd: new_fd,
827 cloexec,
828 },
829 ) => Self::DuplicateFileDescriptorV2 {
830 original_fd: old_fd.to_native(),
831 copied_fd: new_fd.to_native(),
832 cloexec: *cloexec,
833 },
834 ArchivedJournalEntry::CreateDirectoryV1(ArchivedJournalEntryCreateDirectoryV1 {
835 fd,
836 path,
837 }) => Self::CreateDirectoryV1 {
838 fd: fd.to_native(),
839 path: String::from_utf8_lossy(path.as_ref()),
840 },
841 ArchivedJournalEntry::PathSetTimesV1(ArchivedJournalEntryPathSetTimesV1 {
842 fd,
843 path,
844 flags,
845 st_atim,
846 st_mtim,
847 fst_flags,
848 }) => Self::PathSetTimesV1 {
849 fd: fd.to_native(),
850 path: String::from_utf8_lossy(path.as_ref()),
851 flags: flags.to_native(),
852 st_atim: st_atim.to_native(),
853 st_mtim: st_mtim.to_native(),
854 fst_flags: wasi::Fstflags::from_bits_truncate(fst_flags.to_native()),
855 },
856 ArchivedJournalEntry::FileDescriptorSetTimesV1(
857 ArchivedJournalEntryFileDescriptorSetTimesV1 {
858 fd,
859 st_atim,
860 st_mtim,
861 fst_flags,
862 },
863 ) => Self::FileDescriptorSetTimesV1 {
864 fd: fd.to_native(),
865 st_atim: st_atim.to_native(),
866 st_mtim: st_mtim.to_native(),
867 fst_flags: wasi::Fstflags::from_bits_truncate(fst_flags.to_native()),
868 },
869 ArchivedJournalEntry::FileDescriptorSetSizeV1(
870 ArchivedJournalEntryFileDescriptorSetSizeV1 { fd, st_size },
871 ) => Self::FileDescriptorSetSizeV1 {
872 fd: fd.to_native(),
873 st_size: st_size.to_native(),
874 },
875 ArchivedJournalEntry::FileDescriptorSetFdFlagsV1(
876 ArchivedJournalEntryFileDescriptorSetFdFlagsV1 { fd, flags },
877 ) => Self::FileDescriptorSetFdFlagsV1 {
878 fd: fd.to_native(),
879 flags: wasi::Fdflagsext::from_bits_truncate(flags.to_native()),
880 },
881 ArchivedJournalEntry::FileDescriptorSetFlagsV1(
882 ArchivedJournalEntryFileDescriptorSetFlagsV1 { fd, flags },
883 ) => Self::FileDescriptorSetFlagsV1 {
884 fd: fd.to_native(),
885 flags: wasi::Fdflags::from_bits_truncate(flags.to_native()),
886 },
887 ArchivedJournalEntry::FileDescriptorSetRightsV1(
888 ArchivedJournalEntryFileDescriptorSetRightsV1 {
889 fd,
890 fs_rights_base,
891 fs_rights_inheriting,
892 },
893 ) => Self::FileDescriptorSetRightsV1 {
894 fd: fd.to_native(),
895 fs_rights_base: wasi::Rights::from_bits_truncate(fs_rights_base.to_native()),
896 fs_rights_inheriting: wasi::Rights::from_bits_truncate(
897 fs_rights_inheriting.to_native(),
898 ),
899 },
900 ArchivedJournalEntry::FileDescriptorAdviseV1(
901 ArchivedJournalEntryFileDescriptorAdviseV1 {
902 fd,
903 offset,
904 len,
905 advice,
906 },
907 ) => Self::FileDescriptorAdviseV1 {
908 fd: fd.to_native(),
909 offset: offset.to_native(),
910 len: len.to_native(),
911 advice: advice.into(),
912 },
913 ArchivedJournalEntry::FileDescriptorAllocateV1(
914 ArchivedJournalEntryFileDescriptorAllocateV1 { fd, offset, len },
915 ) => Self::FileDescriptorAllocateV1 {
916 fd: fd.to_native(),
917 offset: offset.to_native(),
918 len: len.to_native(),
919 },
920 ArchivedJournalEntry::CreateHardLinkV1(ArchivedJournalEntryCreateHardLinkV1 {
921 old_fd,
922 old_path,
923 old_flags,
924 new_fd,
925 new_path,
926 }) => Self::CreateHardLinkV1 {
927 old_fd: old_fd.to_native(),
928 old_path: String::from_utf8_lossy(old_path.as_ref()),
929 old_flags: old_flags.to_native(),
930 new_fd: new_fd.to_native(),
931 new_path: String::from_utf8_lossy(new_path.as_ref()),
932 },
933 ArchivedJournalEntry::CreateSymbolicLinkV1(
934 ArchivedJournalEntryCreateSymbolicLinkV1 {
935 old_path,
936 fd,
937 new_path,
938 },
939 ) => Self::CreateSymbolicLinkV1 {
940 old_path: String::from_utf8_lossy(old_path.as_ref()),
941 fd: fd.to_native(),
942 new_path: String::from_utf8_lossy(new_path.as_ref()),
943 },
944 ArchivedJournalEntry::ChangeDirectoryV1(ArchivedJournalEntryChangeDirectoryV1 {
945 path,
946 }) => Self::ChangeDirectoryV1 {
947 path: String::from_utf8_lossy(path.as_ref()),
948 },
949 ArchivedJournalEntry::EpollCreateV1(ArchivedJournalEntryEpollCreateV1 { fd }) => {
950 Self::EpollCreateV1 { fd: fd.to_native() }
951 }
952 ArchivedJournalEntry::EpollCtlV1(ArchivedJournalEntryEpollCtlV1 {
953 epfd,
954 op,
955 fd,
956 event,
957 }) => Self::EpollCtlV1 {
958 epfd: epfd.to_native(),
959 op: op.into(),
960 fd: fd.to_native(),
961 event: event.as_ref().map(|e| e.into()),
962 },
963 ArchivedJournalEntry::TtySetV1(ArchivedJournalEntryTtySetV1 {
964 cols,
965 rows,
966 width,
967 height,
968 stdin_tty,
969 stdout_tty,
970 stderr_tty,
971 echo,
972 line_buffered,
973 line_feeds,
974 }) => Self::TtySetV1 {
975 tty: wasi::Tty {
976 cols: cols.to_native(),
977 rows: rows.to_native(),
978 width: width.to_native(),
979 height: height.to_native(),
980 stdin_tty: *stdin_tty,
981 stdout_tty: *stdout_tty,
982 stderr_tty: *stderr_tty,
983 echo: *echo,
984 line_buffered: *line_buffered,
985 },
986 line_feeds: *line_feeds,
987 },
988 ArchivedJournalEntry::CreatePipeV1(ArchivedJournalEntryCreatePipeV1 {
989 read_fd,
990 write_fd,
991 }) => Self::CreatePipeV1 {
992 read_fd: read_fd.to_native(),
993 write_fd: write_fd.to_native(),
994 },
995 ArchivedJournalEntry::PortAddAddrV1(ArchivedJournalEntryPortAddAddrV1 { cidr }) => {
996 Self::PortAddAddrV1 {
997 cidr: JournalIpCidrV1 {
998 ip: cidr.ip.as_ipaddr(),
999 prefix: cidr.prefix,
1000 }
1001 .into(),
1002 }
1003 }
1004 ArchivedJournalEntry::PortDelAddrV1(ArchivedJournalEntryPortDelAddrV1 { addr }) => {
1005 Self::PortDelAddrV1 {
1006 addr: addr.as_ipaddr(),
1007 }
1008 }
1009 ArchivedJournalEntry::PortAddrClearV1 => Self::PortAddrClearV1,
1010 ArchivedJournalEntry::PortBridgeV1(ArchivedJournalEntryPortBridgeV1 {
1011 network,
1012 token,
1013 security,
1014 }) => Self::PortBridgeV1 {
1015 network: String::from_utf8_lossy(network.as_ref()),
1016 token: String::from_utf8_lossy(token.as_ref()),
1017 security: security.into(),
1018 },
1019 ArchivedJournalEntry::PortUnbridgeV1 => Self::PortUnbridgeV1,
1020 ArchivedJournalEntry::PortDhcpAcquireV1 => Self::PortDhcpAcquireV1,
1021 ArchivedJournalEntry::PortGatewaySetV1(ArchivedJournalEntryPortGatewaySetV1 { ip }) => {
1022 Self::PortGatewaySetV1 { ip: ip.as_ipaddr() }
1023 }
1024 ArchivedJournalEntry::PortRouteAddV1(ArchivedJournalEntryPortRouteAddV1 {
1025 cidr,
1026 via_router,
1027 preferred_until,
1028 expires_at,
1029 }) => Self::PortRouteAddV1 {
1030 cidr: JournalIpCidrV1 {
1031 ip: cidr.ip.as_ipaddr(),
1032 prefix: cidr.prefix,
1033 }
1034 .into(),
1035 via_router: via_router.as_ipaddr(),
1036 preferred_until: preferred_until.as_ref().map(|time| (*time).into()),
1037 expires_at: expires_at.as_ref().map(|time| (*time).into()),
1038 },
1039 ArchivedJournalEntry::PortRouteClearV1 => Self::PortRouteClearV1,
1040 ArchivedJournalEntry::PortRouteDelV1(ArchivedJournalEntryPortRouteDelV1 { ip }) => {
1041 Self::PortRouteDelV1 { ip: ip.as_ipaddr() }
1042 }
1043 ArchivedJournalEntry::SocketOpenV1(ArchivedJournalEntrySocketOpenV1 {
1044 af,
1045 ty,
1046 pt,
1047 fd,
1048 }) => Self::SocketOpenV1 {
1049 af: af.into(),
1050 ty: ty.into(),
1051 pt: (pt.to_native()).try_into().unwrap_or(wasi::SockProto::Max),
1052 fd: fd.to_native(),
1053 },
1054 ArchivedJournalEntry::SocketPairV1(ArchivedJournalEntrySocketPairV1 { fd1, fd2 }) => {
1055 Self::SocketPairV1 {
1056 fd1: fd1.to_native(),
1057 fd2: fd2.to_native(),
1058 }
1059 }
1060 ArchivedJournalEntry::SocketListenV1(ArchivedJournalEntrySocketListenV1 {
1061 fd,
1062 backlog,
1063 }) => Self::SocketListenV1 {
1064 fd: fd.to_native(),
1065 backlog: backlog.to_native(),
1066 },
1067 ArchivedJournalEntry::SocketBindV1(ArchivedJournalEntrySocketBindV1 { fd, addr }) => {
1068 Self::SocketBindV1 {
1069 fd: fd.to_native(),
1070 addr: addr.as_socket_addr(),
1071 }
1072 }
1073 ArchivedJournalEntry::SocketConnectedV1(ArchivedJournalEntrySocketConnectedV1 {
1074 fd,
1075 local_addr,
1076 peer_addr,
1077 }) => Self::SocketConnectedV1 {
1078 fd: fd.to_native(),
1079 local_addr: local_addr.as_socket_addr(),
1080 peer_addr: peer_addr.as_socket_addr(),
1081 },
1082 ArchivedJournalEntry::SocketAcceptedV1(ArchivedJournalEntrySocketAcceptedV1 {
1083 listen_fd,
1084 fd,
1085 local_addr,
1086 peer_addr,
1087 fd_flags,
1088 nonblocking,
1089 }) => Self::SocketAcceptedV1 {
1090 listen_fd: listen_fd.to_native(),
1091 fd: fd.to_native(),
1092 local_addr: local_addr.as_socket_addr(),
1093 peer_addr: peer_addr.as_socket_addr(),
1094 fd_flags: wasi::Fdflags::from_bits_truncate(fd_flags.to_native()),
1095 non_blocking: *nonblocking,
1096 },
1097 ArchivedJournalEntry::SocketJoinIpv4MulticastV1(
1098 ArchivedJournalEntrySocketJoinIpv4MulticastV1 {
1099 fd,
1100 multiaddr,
1101 iface,
1102 },
1103 ) => Self::SocketJoinIpv4MulticastV1 {
1104 fd: fd.to_native(),
1105 multiaddr: multiaddr.as_ipv4(),
1106 iface: iface.as_ipv4(),
1107 },
1108 ArchivedJournalEntry::SocketJoinIpv6MulticastV1(
1109 ArchivedJournalEntrySocketJoinIpv6MulticastV1 {
1110 fd,
1111 multiaddr,
1112 iface,
1113 },
1114 ) => Self::SocketJoinIpv6MulticastV1 {
1115 fd: fd.to_native(),
1116 multi_addr: multiaddr.as_ipv6(),
1117 iface: iface.to_native(),
1118 },
1119 ArchivedJournalEntry::SocketLeaveIpv4MulticastV1(
1120 ArchivedJournalEntrySocketLeaveIpv4MulticastV1 {
1121 fd,
1122 multiaddr,
1123 iface,
1124 },
1125 ) => Self::SocketLeaveIpv4MulticastV1 {
1126 fd: fd.to_native(),
1127 multi_addr: multiaddr.as_ipv4(),
1128 iface: iface.as_ipv4(),
1129 },
1130 ArchivedJournalEntry::SocketLeaveIpv6MulticastV1(
1131 ArchivedJournalEntrySocketLeaveIpv6MulticastV1 {
1132 fd,
1133 multiaddr,
1134 iface,
1135 },
1136 ) => Self::SocketLeaveIpv6MulticastV1 {
1137 fd: fd.to_native(),
1138 multi_addr: multiaddr.as_ipv6(),
1139 iface: iface.to_native(),
1140 },
1141 ArchivedJournalEntry::SocketSendFileV1(ArchivedJournalEntrySocketSendFileV1 {
1142 socket_fd,
1143 file_fd,
1144 offset,
1145 count,
1146 }) => Self::SocketSendFileV1 {
1147 socket_fd: socket_fd.to_native(),
1148 file_fd: file_fd.to_native(),
1149 offset: offset.to_native(),
1150 count: count.to_native(),
1151 },
1152 ArchivedJournalEntry::SocketSendToV1(ArchivedJournalEntrySocketSendToV1 {
1153 fd,
1154 data,
1155 flags,
1156 addr,
1157 is_64bit,
1158 }) => Self::SocketSendToV1 {
1159 fd: fd.to_native(),
1160 data: data.as_ref().into(),
1161 flags: flags.to_native(),
1162 addr: addr.as_socket_addr(),
1163 is_64bit: *is_64bit,
1164 },
1165 ArchivedJournalEntry::SocketSendV1(ArchivedJournalEntrySocketSendV1 {
1166 fd,
1167 data,
1168 flags,
1169 is_64bit,
1170 }) => Self::SocketSendV1 {
1171 fd: fd.to_native(),
1172 data: data.as_ref().into(),
1173 flags: flags.to_native(),
1174 is_64bit: *is_64bit,
1175 },
1176 ArchivedJournalEntry::SocketSetOptFlagV1(ArchivedJournalEntrySocketSetOptFlagV1 {
1177 fd,
1178 opt,
1179 flag,
1180 }) => Self::SocketSetOptFlagV1 {
1181 fd: fd.to_native(),
1182 opt: opt.into(),
1183 flag: *flag,
1184 },
1185 ArchivedJournalEntry::SocketSetOptSizeV1(ArchivedJournalEntrySocketSetOptSizeV1 {
1186 fd,
1187 opt,
1188 size,
1189 }) => Self::SocketSetOptSizeV1 {
1190 fd: fd.to_native(),
1191 opt: opt.into(),
1192 size: size.to_native(),
1193 },
1194 ArchivedJournalEntry::SocketSetOptTimeV1(ArchivedJournalEntrySocketSetOptTimeV1 {
1195 fd,
1196 ty,
1197 time,
1198 }) => Self::SocketSetOptTimeV1 {
1199 fd: fd.to_native(),
1200 ty: ty.into(),
1201 time: time.as_ref().map(|time| (*time).into()),
1202 },
1203 ArchivedJournalEntry::SocketShutdownV1(ArchivedJournalEntrySocketShutdownV1 {
1204 fd,
1205 how,
1206 }) => Self::SocketShutdownV1 {
1207 fd: fd.to_native(),
1208 how: how.into(),
1209 },
1210 ArchivedJournalEntry::CreateEventV1(ArchivedJournalEntryCreateEventV1 {
1211 initial_val,
1212 flags,
1213 fd,
1214 }) => Self::CreateEventV1 {
1215 initial_val: initial_val.to_native(),
1216 flags: flags.to_native(),
1217 fd: fd.to_native(),
1218 },
1219 })
1220 }
1221}