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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
//! # User Datagram Protocol Network Messenger //! //! If you're looking to easily send and receive Udp Messages then this crate is perfect for you. //! This gives you the ability to define your own Net Messages by simply creating a struct //! and implementing a trait. The datagrams can be sent with or without a prepended id, and the id can //! be created automatically or manually. //! //! Automatic id generation relies on the name of the datagram, not the layout, so make sure to name //! the datagram structs the same between programs. Additionally, the id generator relies on the hashmap //! hasher, so using different rust versions between programs may change the generated id even if the //! names are the same (if the rust versions differ in how the hasher works). Automatic id generation is //! provided for convenience. It is suggested that you define your own id for each datagram using the set_id //! method. //! //! ## Formats //! //! This crate supports any data format that is also supported by Serde. Not all //! formats are implemented by this crate to reduce the size however they can be implemented by the user //! via the SerDesType trait. See examples of the implementations [here] //! //! [here]: https://github.com/Javagedes/udp_netmsg/blob/master/src/serdes.rs //! //! Convenience Implementations: //! - JSON //! - Bincode //! - YAML //! //! ## Example //! //! ```rust //! use udp_netmsg::prelude::*; //! use serde::{Serialize, Deserialize}; //! use std::{thread, time}; //! //! #[derive(Serialize, Deserialize)] //! struct UpdatePos { //! pub x: f32, //! pub y: f32, //! pub z: f32 //! } //! //! fn main() { //! let mut net_msg = Builder::init().start::<JSON>().unwrap(); //! let pos = UpdatePos{x: 15f32, y: 15f32, z: 15f32}; //! net_msg.send(pos, String::from("127.0.0.1:39507")).unwrap(); //! //! thread::sleep(time::Duration::from_millis(100)); //! //! net_msg.get::<UpdatePos>().unwrap(); //! } //! ``` ///Traits used for implementing SerDes formats and operations pub mod serdes; ///UDP manager and associated methods pub mod manager; #[doc(hidden)] pub mod prelude; #[doc(hidden)] mod util; #[doc(hidden)] mod tests;