wasmer_wasix/journal/effector/syscalls/
sock_send_file.rs

1use crate::syscalls::sock_send_file_internal;
2
3use super::*;
4
5impl JournalEffector {
6    pub fn save_sock_send_file<M: MemorySize>(
7        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
8        socket_fd: Fd,
9        file_fd: Fd,
10        offset: Filesize,
11        count: Filesize,
12    ) -> anyhow::Result<()> {
13        Self::save_event(
14            ctx,
15            JournalEntry::SocketSendFileV1 {
16                socket_fd,
17                file_fd,
18                offset,
19                count,
20            },
21        )
22    }
23
24    pub fn apply_sock_send_file(
25        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
26        socket_fd: Fd,
27        file_fd: Fd,
28        offset: Filesize,
29        count: Filesize,
30    ) -> anyhow::Result<()> {
31        sock_send_file_internal(ctx, socket_fd, file_fd, offset, count)?.map_err(|err| {
32            anyhow::format_err!(
33                "journal restore error: failed to send_file on socket (sock={socket_fd}, in_fd={file_fd}, offset={offset}, count={count}) - {err}")
34        })?;
35        Ok(())
36    }
37}