wasmtime_wasi/host/
instance_network.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::bindings::sockets::instance_network;
use crate::network::Network;
use crate::{WasiImpl, WasiView};
use wasmtime::component::Resource;

impl<T> instance_network::Host for WasiImpl<T>
where
    T: WasiView,
{
    fn instance_network(&mut self) -> Result<Resource<Network>, anyhow::Error> {
        let network = Network {
            socket_addr_check: self.ctx().socket_addr_check.clone(),
            allow_ip_name_lookup: self.ctx().allowed_network_uses.ip_name_lookup,
        };
        let network = self.table().push(network)?;
        Ok(network)
    }
}