wasmer_wasix/journal/effector/syscalls/
port_bridge.rs

1use virtual_net::StreamSecurity;
2
3use super::*;
4
5impl JournalEffector {
6    pub fn save_port_bridge(
7        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
8        network: String,
9        token: String,
10        security: StreamSecurity,
11    ) -> anyhow::Result<()> {
12        Self::save_event(
13            ctx,
14            JournalEntry::PortBridgeV1 {
15                network: network.into(),
16                token: token.into(),
17                security,
18            },
19        )
20    }
21
22    pub fn apply_port_bridge(
23        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
24        network: &str,
25        token: &str,
26        security: StreamSecurity,
27    ) -> anyhow::Result<()> {
28        crate::syscalls::port_bridge_internal(ctx, network, token, security)
29            .map(|r| r.map_err(|err| err.to_string()))
30            .unwrap_or_else(|err| Err(err.to_string()))
31            .map_err(|err| {
32                anyhow::format_err!(
33                    "journal restore error: failed to bridge the network file descriptor (network={network}, security={security:?}) - {err}")
34            })?;
35        Ok(())
36    }
37}