1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
//! An async interface to [libutp](https://github.com/bittorrent/libutp). //! //! //! The main interface of this crate is through the [`UtpContext`], [`UtpSocket`] and [`UtpListener`] structs. //! //! In addition to this, the [`wrappers`] module exposes the unsafe lower level API that the crate is built on, //! which is more in line with the original [libutp](https://github.com/bittorrent/libutp) interface. //! //! **CAUTION**: *Use at your own risk! This crate is a best-effort attempt to provide a safe interface, //! but FFI is inherently unsafe and I (the author) do not have expert knowledge of unsafe rust nor //! the [libutp](https://github.com/bittorrent/libutp) codebase.* mod addrinfo; mod thread; mod udp; mod utp; #[allow(clippy::missing_safety_doc)] pub mod wrappers; pub use utp::Connect; pub use utp::UtpContext; pub use utp::UtpListener; pub use utp::UtpSocket; use std::io; pub type Result<T> = io::Result<T>; #[cfg(test)] mod test_utils { use std::net::SocketAddr; pub fn get_free_socketaddr() -> SocketAddr { use std::net::{IpAddr, Ipv4Addr}; portpicker::pick_unused_port().unwrap(); SocketAddr::new( IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), portpicker::pick_unused_port().unwrap(), ) } }