# Sockit 🧦 [github](https://github.com/wcygan/sockit) [crates.io](https://crates.io/crates/sockit) [docs.rs](https://docs.rs/sockit) [build status](https://github.com/wcygan/sockit/actions?query=branch%3Amain) [![codecov](https://codecov.io/github/wcygan/sockit/branch/main/graph/badge.svg?token=M9M8V24HFW)](https://codecov.io/github/wcygan/sockit) A high-level UDP Socket that allows for writing and reading (de)serializable values # Usage Add this to your Cargo.toml: ```toml [dependencies] sockit = "0.2.1" ``` You can create a Socket by binding it to an address like so: ```rust #[tokio::main] async fn main() { let socket = sockit::UdpSocket::bind("127.0.0.1:0").await?; } ``` You can use the Socket to send and receive serializable objects: ```rust use sockit::UdpSocket; use serde::{Serialize, Deserialize}; /// A (de)serializable type shared between client and server #[derive(Serialize, Deserialize)] struct Message { id: u32, data: String, } /// Code running client side async fn client_side(mut client_socket: UdpSocket) { let message = Message { id: 1, data: "Hello, world!".to_string(), }; client_socket.write::(&message).await.unwrap(); } /// Code running server side async fn server_side(mut server_socket: UdpSocket) { let message: Message = server_socket.read::().await.unwrap().unwrap(); } ```