Expand description
§packetio
A simple, efficient Rust crate for sending and receiving length-prefixed binary packets
over any Read + Write stream using bincode serialization.
§Example
writer.send_packet(&test_struct).unwrap();
let mut size_buf = [0u8; 4];
reader.read_exact(&mut size_buf).unwrap();
let size = parsing::parse_length(size_buf);
let mut packet = vec![0u8; size];
reader.read_exact(&mut packet).unwrap();
let result: TestStruct = parsing::parse_packet(packet).unwrap(); // There you go!Modules§
- parsing
- NOTE! Packets send first its length, then the packet itself. So make sure you aren’t parsing the length and the actual packet in bytes. Example: