Usage
If you're looking to easily send and receive Udp Messages then this crate is perfect for you. It gives you the ability to define your own Net Messages by simply creating a struct and implementing a trait.
Important to note:
- This crate is actively being worked on and interfaces may change from update to update
- This crate will automatically add the user defined header to the front of the datagram. the header id is defined in the fn id() function
- It can optionally include payload length (u32), can be important for target application implementation
- This crate is not for you if you are receiving or sending extremely large udp datagrams as it uses vectors as a buffer. In my light testing, sending/receiving max size udp datagrams (65k bytes), it is about 30% slower than if you were to use an array.
- This crate is designed to send datagrams in BigEndian. You decide how the buffer of data is built, but the 4bytes of header is always as u32 BigEndian. I plan on changing this!
- The recv method returns a trait object Message, but you are able to downcast the message back to the original struct (see example below). I hope to simplify this!
- Currently can only send datagrams to a single ip/port
- If the buffer does not contain enough data for the datagram, It will crash! I plan on fixing this soon
If you have any suggestions for this crate, let me know! If something is not clear or confusing, let me know!
Example
use ;
use Cursor;
use ;
To do
- Check if buffer is large enough for datagram. Have it return None instead of crashing
- Allow users to choose bigEndian or littleEndian for header / payload length
- Simplify downcasting