wasmer_journal/concrete/
archived_from.rs

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        }
618    }
619}
620
621impl From<&'_ ArchivedJournalWasiMemoryLayout> for WasiMemoryLayout {
622    fn from(value: &'_ ArchivedJournalWasiMemoryLayout) -> Self {
623        Self {
624            stack_upper: value.stack_upper.to_native(),
625            stack_lower: value.stack_lower.to_native(),
626            guard_size: value.guard_size.to_native(),
627            stack_size: value.stack_size.to_native(),
628        }
629    }
630}
631
632impl From<WasiMemoryLayout> for JournalWasiMemoryLayout {
633    fn from(value: WasiMemoryLayout) -> Self {
634        Self {
635            stack_upper: value.stack_upper,
636            stack_lower: value.stack_lower,
637            guard_size: value.guard_size,
638            stack_size: value.stack_size,
639        }
640    }
641}
642
643impl<'a> TryFrom<ArchivedJournalEntry<'a>> for JournalEntry<'a> {
644    type Error = anyhow::Error;
645
646    fn try_from(value: ArchivedJournalEntry<'a>) -> anyhow::Result<Self> {
647        Ok(match value {
648            ArchivedJournalEntry::InitModuleV1(ArchivedJournalEntryInitModuleV1 { wasm_hash }) => {
649                Self::InitModuleV1 {
650                    wasm_hash: Box::from(wasm_hash.get()),
651                }
652            }
653            ArchivedJournalEntry::ClearEtherealV1(ArchivedJournalEntryClearEtherealV1 {
654                ..
655            }) => Self::ClearEtherealV1,
656            ArchivedJournalEntry::UpdateMemoryRegionV1(
657                ArchivedJournalEntryUpdateMemoryRegionV1 {
658                    start,
659                    end,
660                    compressed_data,
661                },
662            ) => Self::UpdateMemoryRegionV1 {
663                region: (start.to_native())..(end.to_native()),
664                compressed_data: Cow::Borrowed(compressed_data.as_ref()),
665            },
666            ArchivedJournalEntry::ProcessExitV1(ArchivedJournalEntryProcessExitV1 {
667                exit_code,
668            }) => Self::ProcessExitV1 {
669                exit_code: exit_code.as_ref().map(|code| code.into()),
670            },
671            ArchivedJournalEntry::SetThreadV1(ArchivedJournalEntrySetThreadV1 {
672                id,
673                call_stack,
674                memory_stack,
675                store_data,
676                is_64bit,
677                start,
678                layout,
679            }) => Self::SetThreadV1 {
680                id: id.to_native(),
681                call_stack: call_stack.as_ref().into(),
682                memory_stack: memory_stack.as_ref().into(),
683                store_data: store_data.as_ref().into(),
684                start: start.into(),
685                layout: layout.into(),
686                is_64bit: *is_64bit,
687            },
688            ArchivedJournalEntry::CloseThreadV1(ArchivedJournalEntryCloseThreadV1 {
689                id,
690                exit_code,
691            }) => Self::CloseThreadV1 {
692                id: id.to_native(),
693                exit_code: exit_code.as_ref().map(|code| code.into()),
694            },
695            ArchivedJournalEntry::FileDescriptorWriteV1(
696                ArchivedJournalEntryFileDescriptorWriteV1 {
697                    data,
698                    fd,
699                    offset,
700                    is_64bit,
701                },
702            ) => Self::FileDescriptorWriteV1 {
703                data: data.as_ref().into(),
704                fd: fd.to_native(),
705                offset: offset.to_native(),
706                is_64bit: *is_64bit,
707            },
708            ArchivedJournalEntry::FileDescriptorSeekV1(
709                ArchivedJournalEntryFileDescriptorSeekV1 {
710                    fd,
711                    offset,
712                    ref whence,
713                },
714            ) => Self::FileDescriptorSeekV1 {
715                fd: fd.to_native(),
716                offset: offset.to_native(),
717                whence: whence.into(),
718            },
719            ArchivedJournalEntry::OpenFileDescriptorV1(
720                ArchivedJournalEntryOpenFileDescriptorV1 {
721                    fd,
722                    dirfd,
723                    dirflags,
724                    path,
725                    o_flags,
726                    fs_rights_base,
727                    fs_rights_inheriting,
728                    fs_flags,
729                },
730            ) => Self::OpenFileDescriptorV1 {
731                fd: fd.to_native(),
732                dirfd: dirfd.to_native(),
733                dirflags: dirflags.to_native(),
734                path: String::from_utf8_lossy(path.as_ref()),
735                o_flags: wasi::Oflags::from_bits_truncate(o_flags.to_native()),
736                fs_rights_base: wasi::Rights::from_bits_truncate(fs_rights_base.to_native()),
737                fs_rights_inheriting: wasi::Rights::from_bits_truncate(
738                    fs_rights_inheriting.to_native(),
739                ),
740                fs_flags: wasi::Fdflags::from_bits_truncate(fs_flags.to_native()),
741            },
742            ArchivedJournalEntry::OpenFileDescriptorV2(
743                ArchivedJournalEntryOpenFileDescriptorV2 {
744                    fd,
745                    dirfd,
746                    dirflags,
747                    path,
748                    o_flags,
749                    fs_rights_base,
750                    fs_rights_inheriting,
751                    fs_flags,
752                    fd_flags,
753                },
754            ) => Self::OpenFileDescriptorV2 {
755                fd: fd.to_native(),
756                dirfd: dirfd.to_native(),
757                dirflags: dirflags.to_native(),
758                path: String::from_utf8_lossy(path.as_ref()),
759                o_flags: wasi::Oflags::from_bits_truncate(o_flags.to_native()),
760                fs_rights_base: wasi::Rights::from_bits_truncate(fs_rights_base.to_native()),
761                fs_rights_inheriting: wasi::Rights::from_bits_truncate(
762                    fs_rights_inheriting.to_native(),
763                ),
764                fs_flags: wasi::Fdflags::from_bits_truncate(fs_flags.to_native()),
765                fd_flags: wasi::Fdflagsext::from_bits_truncate(fd_flags.to_native()),
766            },
767            ArchivedJournalEntry::CloseFileDescriptorV1(
768                ArchivedJournalEntryCloseFileDescriptorV1 { fd },
769            ) => Self::CloseFileDescriptorV1 { fd: fd.to_native() },
770            ArchivedJournalEntry::RemoveDirectoryV1(ArchivedJournalEntryRemoveDirectoryV1 {
771                fd,
772                path,
773            }) => Self::RemoveDirectoryV1 {
774                fd: fd.to_native(),
775                path: String::from_utf8_lossy(path.as_ref()),
776            },
777            ArchivedJournalEntry::UnlinkFileV1(ArchivedJournalEntryUnlinkFileV1 { fd, path }) => {
778                Self::UnlinkFileV1 {
779                    fd: fd.to_native(),
780                    path: String::from_utf8_lossy(path.as_ref()),
781                }
782            }
783            ArchivedJournalEntry::PathRenameV1(ArchivedJournalEntryPathRenameV1 {
784                old_fd,
785                old_path,
786                new_fd,
787                new_path,
788            }) => Self::PathRenameV1 {
789                old_fd: old_fd.to_native(),
790                old_path: String::from_utf8_lossy(old_path.as_ref()),
791                new_fd: new_fd.to_native(),
792                new_path: String::from_utf8_lossy(new_path.as_ref()),
793            },
794            ArchivedJournalEntry::SnapshotV1(ArchivedJournalEntrySnapshotV1 {
795                since_epoch,
796                ref trigger,
797            }) => Self::SnapshotV1 {
798                when: SystemTime::UNIX_EPOCH
799                    .checked_add((*since_epoch).into())
800                    .unwrap_or(SystemTime::UNIX_EPOCH),
801                trigger: trigger.into(),
802            },
803            ArchivedJournalEntry::SetClockTimeV1(ArchivedJournalEntrySetClockTimeV1 {
804                ref clock_id,
805                time,
806            }) => Self::SetClockTimeV1 {
807                clock_id: clock_id.into(),
808                time: time.to_native(),
809            },
810            ArchivedJournalEntry::RenumberFileDescriptorV1(
811                ArchivedJournalEntryRenumberFileDescriptorV1 { old_fd, new_fd },
812            ) => Self::RenumberFileDescriptorV1 {
813                old_fd: old_fd.to_native(),
814                new_fd: new_fd.to_native(),
815            },
816            ArchivedJournalEntry::DuplicateFileDescriptorV1(
817                ArchivedJournalEntryDuplicateFileDescriptorV1 {
818                    original_fd: old_fd,
819                    copied_fd: new_fd,
820                },
821            ) => Self::DuplicateFileDescriptorV1 {
822                original_fd: old_fd.to_native(),
823                copied_fd: new_fd.to_native(),
824            },
825            ArchivedJournalEntry::DuplicateFileDescriptorV2(
826                ArchivedJournalEntryDuplicateFileDescriptorV2 {
827                    original_fd: old_fd,
828                    copied_fd: new_fd,
829                    cloexec,
830                },
831            ) => Self::DuplicateFileDescriptorV2 {
832                original_fd: old_fd.to_native(),
833                copied_fd: new_fd.to_native(),
834                cloexec: *cloexec,
835            },
836            ArchivedJournalEntry::CreateDirectoryV1(ArchivedJournalEntryCreateDirectoryV1 {
837                fd,
838                path,
839            }) => Self::CreateDirectoryV1 {
840                fd: fd.to_native(),
841                path: String::from_utf8_lossy(path.as_ref()),
842            },
843            ArchivedJournalEntry::PathSetTimesV1(ArchivedJournalEntryPathSetTimesV1 {
844                fd,
845                path,
846                flags,
847                st_atim,
848                st_mtim,
849                fst_flags,
850            }) => Self::PathSetTimesV1 {
851                fd: fd.to_native(),
852                path: String::from_utf8_lossy(path.as_ref()),
853                flags: flags.to_native(),
854                st_atim: st_atim.to_native(),
855                st_mtim: st_mtim.to_native(),
856                fst_flags: wasi::Fstflags::from_bits_truncate(fst_flags.to_native()),
857            },
858            ArchivedJournalEntry::FileDescriptorSetTimesV1(
859                ArchivedJournalEntryFileDescriptorSetTimesV1 {
860                    fd,
861                    st_atim,
862                    st_mtim,
863                    fst_flags,
864                },
865            ) => Self::FileDescriptorSetTimesV1 {
866                fd: fd.to_native(),
867                st_atim: st_atim.to_native(),
868                st_mtim: st_mtim.to_native(),
869                fst_flags: wasi::Fstflags::from_bits_truncate(fst_flags.to_native()),
870            },
871            ArchivedJournalEntry::FileDescriptorSetSizeV1(
872                ArchivedJournalEntryFileDescriptorSetSizeV1 { fd, st_size },
873            ) => Self::FileDescriptorSetSizeV1 {
874                fd: fd.to_native(),
875                st_size: st_size.to_native(),
876            },
877            ArchivedJournalEntry::FileDescriptorSetFdFlagsV1(
878                ArchivedJournalEntryFileDescriptorSetFdFlagsV1 { fd, flags },
879            ) => Self::FileDescriptorSetFdFlagsV1 {
880                fd: fd.to_native(),
881                flags: wasi::Fdflagsext::from_bits_truncate(flags.to_native()),
882            },
883            ArchivedJournalEntry::FileDescriptorSetFlagsV1(
884                ArchivedJournalEntryFileDescriptorSetFlagsV1 { fd, flags },
885            ) => Self::FileDescriptorSetFlagsV1 {
886                fd: fd.to_native(),
887                flags: wasi::Fdflags::from_bits_truncate(flags.to_native()),
888            },
889            ArchivedJournalEntry::FileDescriptorSetRightsV1(
890                ArchivedJournalEntryFileDescriptorSetRightsV1 {
891                    fd,
892                    fs_rights_base,
893                    fs_rights_inheriting,
894                },
895            ) => Self::FileDescriptorSetRightsV1 {
896                fd: fd.to_native(),
897                fs_rights_base: wasi::Rights::from_bits_truncate(fs_rights_base.to_native()),
898                fs_rights_inheriting: wasi::Rights::from_bits_truncate(
899                    fs_rights_inheriting.to_native(),
900                ),
901            },
902            ArchivedJournalEntry::FileDescriptorAdviseV1(
903                ArchivedJournalEntryFileDescriptorAdviseV1 {
904                    fd,
905                    offset,
906                    len,
907                    ref advice,
908                },
909            ) => Self::FileDescriptorAdviseV1 {
910                fd: fd.to_native(),
911                offset: offset.to_native(),
912                len: len.to_native(),
913                advice: advice.into(),
914            },
915            ArchivedJournalEntry::FileDescriptorAllocateV1(
916                ArchivedJournalEntryFileDescriptorAllocateV1 { fd, offset, len },
917            ) => Self::FileDescriptorAllocateV1 {
918                fd: fd.to_native(),
919                offset: offset.to_native(),
920                len: len.to_native(),
921            },
922            ArchivedJournalEntry::CreateHardLinkV1(ArchivedJournalEntryCreateHardLinkV1 {
923                old_fd,
924                old_path,
925                old_flags,
926                new_fd,
927                new_path,
928            }) => Self::CreateHardLinkV1 {
929                old_fd: old_fd.to_native(),
930                old_path: String::from_utf8_lossy(old_path.as_ref()),
931                old_flags: old_flags.to_native(),
932                new_fd: new_fd.to_native(),
933                new_path: String::from_utf8_lossy(new_path.as_ref()),
934            },
935            ArchivedJournalEntry::CreateSymbolicLinkV1(
936                ArchivedJournalEntryCreateSymbolicLinkV1 {
937                    old_path,
938                    fd,
939                    new_path,
940                },
941            ) => Self::CreateSymbolicLinkV1 {
942                old_path: String::from_utf8_lossy(old_path.as_ref()),
943                fd: fd.to_native(),
944                new_path: String::from_utf8_lossy(new_path.as_ref()),
945            },
946            ArchivedJournalEntry::ChangeDirectoryV1(ArchivedJournalEntryChangeDirectoryV1 {
947                path,
948            }) => Self::ChangeDirectoryV1 {
949                path: String::from_utf8_lossy(path.as_ref()),
950            },
951            ArchivedJournalEntry::EpollCreateV1(ArchivedJournalEntryEpollCreateV1 { fd }) => {
952                Self::EpollCreateV1 { fd: fd.to_native() }
953            }
954            ArchivedJournalEntry::EpollCtlV1(ArchivedJournalEntryEpollCtlV1 {
955                epfd,
956                ref op,
957                fd,
958                ref event,
959            }) => Self::EpollCtlV1 {
960                epfd: epfd.to_native(),
961                op: op.into(),
962                fd: fd.to_native(),
963                event: event.as_ref().map(|e| e.into()),
964            },
965            ArchivedJournalEntry::TtySetV1(ArchivedJournalEntryTtySetV1 {
966                cols,
967                rows,
968                width,
969                height,
970                stdin_tty,
971                stdout_tty,
972                stderr_tty,
973                echo,
974                line_buffered,
975                line_feeds,
976            }) => Self::TtySetV1 {
977                tty: wasi::Tty {
978                    cols: cols.to_native(),
979                    rows: rows.to_native(),
980                    width: width.to_native(),
981                    height: height.to_native(),
982                    stdin_tty: *stdin_tty,
983                    stdout_tty: *stdout_tty,
984                    stderr_tty: *stderr_tty,
985                    echo: *echo,
986                    line_buffered: *line_buffered,
987                },
988                line_feeds: *line_feeds,
989            },
990            ArchivedJournalEntry::CreatePipeV1(ArchivedJournalEntryCreatePipeV1 {
991                read_fd,
992                write_fd,
993            }) => Self::CreatePipeV1 {
994                read_fd: read_fd.to_native(),
995                write_fd: write_fd.to_native(),
996            },
997            ArchivedJournalEntry::PortAddAddrV1(ArchivedJournalEntryPortAddAddrV1 { cidr }) => {
998                Self::PortAddAddrV1 {
999                    cidr: JournalIpCidrV1 {
1000                        ip: cidr.ip.as_ipaddr(),
1001                        prefix: cidr.prefix,
1002                    }
1003                    .into(),
1004                }
1005            }
1006            ArchivedJournalEntry::PortDelAddrV1(ArchivedJournalEntryPortDelAddrV1 { addr }) => {
1007                Self::PortDelAddrV1 {
1008                    addr: addr.as_ipaddr(),
1009                }
1010            }
1011            ArchivedJournalEntry::PortAddrClearV1 => Self::PortAddrClearV1,
1012            ArchivedJournalEntry::PortBridgeV1(ArchivedJournalEntryPortBridgeV1 {
1013                network,
1014                token,
1015                ref security,
1016            }) => Self::PortBridgeV1 {
1017                network: String::from_utf8_lossy(network.as_ref()),
1018                token: String::from_utf8_lossy(token.as_ref()),
1019                security: security.into(),
1020            },
1021            ArchivedJournalEntry::PortUnbridgeV1 => Self::PortUnbridgeV1,
1022            ArchivedJournalEntry::PortDhcpAcquireV1 => Self::PortDhcpAcquireV1,
1023            ArchivedJournalEntry::PortGatewaySetV1(ArchivedJournalEntryPortGatewaySetV1 { ip }) => {
1024                Self::PortGatewaySetV1 { ip: ip.as_ipaddr() }
1025            }
1026            ArchivedJournalEntry::PortRouteAddV1(ArchivedJournalEntryPortRouteAddV1 {
1027                cidr,
1028                via_router,
1029                preferred_until,
1030                expires_at,
1031            }) => Self::PortRouteAddV1 {
1032                cidr: JournalIpCidrV1 {
1033                    ip: cidr.ip.as_ipaddr(),
1034                    prefix: cidr.prefix,
1035                }
1036                .into(),
1037                via_router: via_router.as_ipaddr(),
1038                preferred_until: preferred_until.as_ref().map(|time| (*time).into()),
1039                expires_at: expires_at.as_ref().map(|time| (*time).into()),
1040            },
1041            ArchivedJournalEntry::PortRouteClearV1 => Self::PortRouteClearV1,
1042            ArchivedJournalEntry::PortRouteDelV1(ArchivedJournalEntryPortRouteDelV1 { ip }) => {
1043                Self::PortRouteDelV1 { ip: ip.as_ipaddr() }
1044            }
1045            ArchivedJournalEntry::SocketOpenV1(ArchivedJournalEntrySocketOpenV1 {
1046                ref af,
1047                ref ty,
1048                pt,
1049                fd,
1050            }) => Self::SocketOpenV1 {
1051                af: af.into(),
1052                ty: ty.into(),
1053                pt: (pt.to_native()).try_into().unwrap_or(wasi::SockProto::Max),
1054                fd: fd.to_native(),
1055            },
1056            ArchivedJournalEntry::SocketPairV1(ArchivedJournalEntrySocketPairV1 { fd1, fd2 }) => {
1057                Self::SocketPairV1 {
1058                    fd1: fd1.to_native(),
1059                    fd2: fd2.to_native(),
1060                }
1061            }
1062            ArchivedJournalEntry::SocketListenV1(ArchivedJournalEntrySocketListenV1 {
1063                fd,
1064                backlog,
1065            }) => Self::SocketListenV1 {
1066                fd: fd.to_native(),
1067                backlog: backlog.to_native(),
1068            },
1069            ArchivedJournalEntry::SocketBindV1(ArchivedJournalEntrySocketBindV1 { fd, addr }) => {
1070                Self::SocketBindV1 {
1071                    fd: fd.to_native(),
1072                    addr: addr.as_socket_addr(),
1073                }
1074            }
1075            ArchivedJournalEntry::SocketConnectedV1(ArchivedJournalEntrySocketConnectedV1 {
1076                fd,
1077                local_addr,
1078                peer_addr,
1079            }) => Self::SocketConnectedV1 {
1080                fd: fd.to_native(),
1081                local_addr: local_addr.as_socket_addr(),
1082                peer_addr: peer_addr.as_socket_addr(),
1083            },
1084            ArchivedJournalEntry::SocketAcceptedV1(ArchivedJournalEntrySocketAcceptedV1 {
1085                listen_fd,
1086                fd,
1087                local_addr,
1088                peer_addr,
1089                fd_flags,
1090                nonblocking,
1091            }) => Self::SocketAcceptedV1 {
1092                listen_fd: listen_fd.to_native(),
1093                fd: fd.to_native(),
1094                local_addr: local_addr.as_socket_addr(),
1095                peer_addr: peer_addr.as_socket_addr(),
1096                fd_flags: wasi::Fdflags::from_bits_truncate(fd_flags.to_native()),
1097                non_blocking: *nonblocking,
1098            },
1099            ArchivedJournalEntry::SocketJoinIpv4MulticastV1(
1100                ArchivedJournalEntrySocketJoinIpv4MulticastV1 {
1101                    fd,
1102                    multiaddr,
1103                    iface,
1104                },
1105            ) => Self::SocketJoinIpv4MulticastV1 {
1106                fd: fd.to_native(),
1107                multiaddr: multiaddr.as_ipv4(),
1108                iface: iface.as_ipv4(),
1109            },
1110            ArchivedJournalEntry::SocketJoinIpv6MulticastV1(
1111                ArchivedJournalEntrySocketJoinIpv6MulticastV1 {
1112                    fd,
1113                    multiaddr,
1114                    iface,
1115                },
1116            ) => Self::SocketJoinIpv6MulticastV1 {
1117                fd: fd.to_native(),
1118                multi_addr: multiaddr.as_ipv6(),
1119                iface: iface.to_native(),
1120            },
1121            ArchivedJournalEntry::SocketLeaveIpv4MulticastV1(
1122                ArchivedJournalEntrySocketLeaveIpv4MulticastV1 {
1123                    fd,
1124                    multiaddr,
1125                    iface,
1126                },
1127            ) => Self::SocketLeaveIpv4MulticastV1 {
1128                fd: fd.to_native(),
1129                multi_addr: multiaddr.as_ipv4(),
1130                iface: iface.as_ipv4(),
1131            },
1132            ArchivedJournalEntry::SocketLeaveIpv6MulticastV1(
1133                ArchivedJournalEntrySocketLeaveIpv6MulticastV1 {
1134                    fd,
1135                    multiaddr,
1136                    iface,
1137                },
1138            ) => Self::SocketLeaveIpv6MulticastV1 {
1139                fd: fd.to_native(),
1140                multi_addr: multiaddr.as_ipv6(),
1141                iface: iface.to_native(),
1142            },
1143            ArchivedJournalEntry::SocketSendFileV1(ArchivedJournalEntrySocketSendFileV1 {
1144                socket_fd,
1145                file_fd,
1146                offset,
1147                count,
1148            }) => Self::SocketSendFileV1 {
1149                socket_fd: socket_fd.to_native(),
1150                file_fd: file_fd.to_native(),
1151                offset: offset.to_native(),
1152                count: count.to_native(),
1153            },
1154            ArchivedJournalEntry::SocketSendToV1(ArchivedJournalEntrySocketSendToV1 {
1155                fd,
1156                data,
1157                flags,
1158                addr,
1159                is_64bit,
1160            }) => Self::SocketSendToV1 {
1161                fd: fd.to_native(),
1162                data: data.as_ref().into(),
1163                flags: flags.to_native(),
1164                addr: addr.as_socket_addr(),
1165                is_64bit: *is_64bit,
1166            },
1167            ArchivedJournalEntry::SocketSendV1(ArchivedJournalEntrySocketSendV1 {
1168                fd,
1169                data,
1170                flags,
1171                is_64bit,
1172            }) => Self::SocketSendV1 {
1173                fd: fd.to_native(),
1174                data: data.as_ref().into(),
1175                flags: flags.to_native(),
1176                is_64bit: *is_64bit,
1177            },
1178            ArchivedJournalEntry::SocketSetOptFlagV1(ArchivedJournalEntrySocketSetOptFlagV1 {
1179                fd,
1180                ref opt,
1181                flag,
1182            }) => Self::SocketSetOptFlagV1 {
1183                fd: fd.to_native(),
1184                opt: opt.into(),
1185                flag: *flag,
1186            },
1187            ArchivedJournalEntry::SocketSetOptSizeV1(ArchivedJournalEntrySocketSetOptSizeV1 {
1188                fd,
1189                ref opt,
1190                size,
1191            }) => Self::SocketSetOptSizeV1 {
1192                fd: fd.to_native(),
1193                opt: opt.into(),
1194                size: size.to_native(),
1195            },
1196            ArchivedJournalEntry::SocketSetOptTimeV1(ArchivedJournalEntrySocketSetOptTimeV1 {
1197                fd,
1198                ref ty,
1199                time,
1200            }) => Self::SocketSetOptTimeV1 {
1201                fd: fd.to_native(),
1202                ty: ty.into(),
1203                time: time.as_ref().map(|time| (*time).into()),
1204            },
1205            ArchivedJournalEntry::SocketShutdownV1(ArchivedJournalEntrySocketShutdownV1 {
1206                fd,
1207                ref how,
1208            }) => Self::SocketShutdownV1 {
1209                fd: fd.to_native(),
1210                how: how.into(),
1211            },
1212            ArchivedJournalEntry::CreateEventV1(ArchivedJournalEntryCreateEventV1 {
1213                initial_val,
1214                flags,
1215                fd,
1216            }) => Self::CreateEventV1 {
1217                initial_val: initial_val.to_native(),
1218                flags: flags.to_native(),
1219                fd: fd.to_native(),
1220            },
1221        })
1222    }
1223}