smolboi is a prototype of a chat server written in Rust using async
I/O, driven by the
smol async runtime. It also contains a sample
linetest, which is useful for testing & debugging.
cargo buildin the root of this workspace to build all crates within the workspace simultaneously.
cargo run --bin serverto start the server on localhost.
cargo run --bin linetestto start the client.
The codec for the chat protocol can be found in
protocol::packet module. In general the protocol works as follows:
The first two bytes on the wire(network byte-order) represent the length of
the packet to be decoded. This tells a receiver how many bytes to read.
The receiver should allocate a buffer of that size and pass the resultant
NOTE: as a consequence a packet can be no greater than u16::MAX bytes long, e.g: 64KiB total.
It is important to note that this is not a general purpose serialization
format, it is a purpose-built binary mapping of the packets enumerated by
In general packet fields are arranged on the wire in the order they are listed in the enumeration, types will be encoded as follows:
bool is encoded as a
u8 which is either
String is encoded as a length (
u16) and then a series of bytes
representing a UTF-8 encoded string.
u16::MAXis an error and must be rejected by a conforming sender.
Integer types will be represented on the wire as bytes in network endian order.
Arrays will be encoded similarly to strings: however the u16 length prefix will represent the number of elements in the array. All arrays will be heterogeneous: and contain only the objects described above.
linetest crate contains basic line editing functionality, as well as a
scrollable line-oriented buffer. This client is cross-platform, w/ the low-level
terminal handling provided by the
crossterm crate. Current functionality