///|
#borrow(bind_ip)
extern "c" fn udp_open_ffi(bind_ip : Bytes, bind_port : Int) -> Int = "lockwire_native_udp_open"
///|
extern "c" fn udp_bound_port_ffi(fd : Int) -> Int = "lockwire_native_udp_bound_port"
///|
#borrow(ip, data)
extern "c" fn udp_send_to_ffi(
fd : Int,
ip : Bytes,
port : Int,
data : Bytes,
) -> Int = "lockwire_native_udp_sendto"
///|
extern "c" fn udp_receive_ffi(fd : Int, timeout_ms : Int) -> Bytes = "lockwire_native_udp_receive"
///|
extern "c" fn udp_close_ffi(fd : Int) -> Int = "lockwire_native_udp_close"
///|
fn ffi_udp_open(bind_ip : Bytes, bind_port : Int) -> Int {
udp_open_ffi(bind_ip, bind_port)
}
///|
fn ffi_udp_bound_port(fd : Int) -> Int {
udp_bound_port_ffi(fd)
}
///|
fn ffi_udp_send_to(fd : Int, ip : Bytes, port : Int, data : Bytes) -> Int {
udp_send_to_ffi(fd, ip, port, data)
}
///|
fn ffi_udp_receive(fd : Int, timeout_ms : Int) -> Bytes {
udp_receive_ffi(fd, timeout_ms)
}
///|
fn ffi_udp_close(fd : Int) -> Int {
udp_close_ffi(fd)
}