[−][src]Module tobytcp::protocol
Includes methods for generating the tobytcp
prefix, or attempting to decode the length of
the encoded data i.e. payload, from a buffer.
Examples
Getting the tobytcp
length prefix that will preceed the data
use tobytcp::protocol::tobytcp_prefix; let data = vec![1, 2, 3]; let mut len_buf = tobytcp_prefix(data.len()); // Send `len_buf` first, then `data`
Decoding the length of an inbound tobytcp
message from a stream
use tobytcp::protocol::tobytcp_len; let mut len_buf = [0; 8]; stream.read(&mut len_buf); let msg_len = tobytcp_len(len_buf); // Now we know that the next message payload is `msg_len` bytes in length..
Functions
tobytcp_len | For an 8 byte buf, what is the length of the data. Module level documentation has more info. |
tobytcp_prefix | For some size, get the prefix that represents that size. Module level documentation has more info. |